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 ?

13th Oct 2017, 1:00 PM
Bilal Naeem
Bilal Naeem - avatar
2 Antworten
+ 3
It indicates the base. Here, binary is base 2, hence the number 2 is used. Hope this helps! :)
13th Oct 2017, 2:33 PM
Shinjini Ghosh
+ 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))
13th Oct 2017, 3:43 PM
Kirk Schafer
Kirk Schafer - avatar