Int()'s Second Parameter


What does the second parameter “2” do in relation to the binary number?

print int("1",2)
print int("10",2)
print int("111",2)
print int("0b100",2)
print int(bin(5),2)
# Print out the decimal equivalent of the binary 11001001.
print int("11001001",2)


As far as I can tell, the second parameter is what decides the radix of the integer. In this instance, the radix is being set to 2, which means there are two possible digits available, 0 or 1. You can continue this logic with a radix of three having the values 0, 1, and 2


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.