0
binary = input("Enter number in Binary Format: ") decimal = int(binary, 2) print("\n",binary,"in Decimal =",decimal)
in int why 2 is used ?and what does it mean ?
2 Respostas
+ 3
It indicates the base. Here, binary is base 2, hence the number 2 is used. Hope this helps! :)
+ 2
int() takes a second parameter, which you can read about on CodePlayground:
print(int.__doc__)
Python doesn't care about the variable name here. The 2 just picks a number system that uses two symbols to count instead of ten. The symbols chosen are 0 and 1 because it makes more sense to us (but any two choices like yes/no and true/false are 'bi-nary' choices)
For more complete info (way more text):
print(help(int))