When you call int(), you are giving it two parameters: '100', and 2. The first parameter it takes is the number as a string, and the second is the base. So, you are telling it to convert the string '100' into an integer of base 2. 100 in base 2 is four, so you are getting this output. Hope this helps!
The int(x,base) function converts a number from a specified base to a decimal integer. 100 in base 2 is 4 in base 10.
When you call
int()
, you are giving it two parameters:'100'
, and2
. The first parameter it takes is the number as a string, and the second is the base. So, you are telling it to convert the string'100'
into an integer of base 2. 100 in base 2 is four, so you are getting this output. Hope this helps!二进制系统中的100是1 * 2 ^ 2 * 0 * 2 ^ 1 + 0 = 4