base_convert.py

Created by toronico07

Created on September 30, 2021

1.18 KB

Un script pour convertir un nombre sous différentes base.


#Introduction
print("Bonjour. Bienvenue dans base_convert.py créer par nt games !")
print("")

activer = True
while activer == True:
    #Choix
    print("Choisis ce que tu veux convertir :")

    print("1 - Base 10 en binaire")
    print("2 - Binaire en base 10")
    print("3 - Base 10 en hexadécimal")
    print("4 - Hexadécimal en base 10")
    print("5 - N'importe quelle base en base 10")

    choix = str(input("Choix : "))
    print("")

    #Base 10 en binaire
    if choix == "1":
        nombre = int(input("Nombre : "))
        print(bin(nombre)[2:])
        print("")

    #Binaire en base 10
    if choix == "2":
        binaire = input("Binaire : ")
        print(int(binaire, 2))
        print("")

    #Base 10 en hexadécimal
    if choix == "3":
        nombre = int(input("Nombre : "))
        print(hex(nombre)[2:])
        print("")

    #Hexadécimal en base 10
    if choix == "4":
        hexadecimal = input("Hexadecimal : ")
        print(int(hexadecimal, 16))
        print("")

    #N'importe quelle base en base 10
    if choix == "5":
        base = int(input("Base : "))
        nombre = input("Nombre : ")
        print(int(nombre, base))
        print("")

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.