Ce programme permet de convertir les nombres décimal, binaire et hexadécimal.
from math import* choix=0 def info(): print() print("Convertir un nombre :") print("1. décimal") print("2. binaire") print("3. hexadécimal") reponse=1 while reponse==1 or reponse==2 or reponse==3 : info() choix=input("-> ") if choix == "0" : info() if choix == "1" : decimal=int(input("Nombre décimal : ")) print("> Forme binaire :", bin(decimal).lstrip("0b").rstrip("L")) print("> Forme hexadécimal :", hex(decimal).lstrip("0x").rstrip("L")) reponse=int(input("Réessayer ? ")) if choix == "2" : binaire=input("Nombre binaire : ") b=int(str(binaire),2) print("> Forme décimal :", b) print("> Forme hexadécimal :", hex(b).lstrip("0x").rstrip("L")) reponse=int(input("Réessayer ? ")) if choix == "3" : hexa=input("Nombre hexadécimal : ") h=int(str(hexa),16) print("> Forme décimal :", h) print("> Forme binaire :", bin(h).lstrip("0b").rstrip("L")) reponse=int(input("Réessayer ? "))