A voir également:
- Convertir binaire en décimal python
- Telecharger macro convertir chiffre en lettre excel - Télécharger - Tableur
- Binaire - Guide
- Citizen code python avis - Accueil - Outils
- Convertir epub en kindle - Guide
- Convertir youtube en mp3 avec audacity - Guide
2 réponses
A moins que ce ne soit un exercice (encore un exercice qui n'apprend pas à utiliser les outils préexistants et facilités d'un langage), ce code est inutile et imbuvable (pour calculer une puissance on utilise Horner, notamment )
Ceci suffit:
Utilise ton interpréteur préféré::
Gates gave ^H sold you the windows.
GNU gave us the whole house.(Alexandrin)
Ceci suffit:
string37='100101'
print(int(string37, 2))
Utilise ton interpréteur préféré::
>>> doc=int.__doc__
>>> print( doc )
int(x=0) -> integer
int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments
are given. If x is a number, return x.__int__(). For floating point
numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string,
bytes, or bytearray instance representing an integer literal in the
given base. The literal can be preceded by '+' or '-' and be surrounded
by whitespace. The base defaults to 10. Valid bases are 0 and 2-36.
Base 0 means to interpret the base from the string as an integer literal.
>>> int('0b100', base=0)
Gates gave ^H sold you the windows.
GNU gave us the whole house.(Alexandrin)