def main():
wahl =0
while(1):
liste=[]
wahl=menue()
if (wahl > 3):
break
zahl=input ("Bitte geben sie eine Dezimalzahl ein: ")
if wahl == 1:
liste=dual(zahl,liste)
if wahl == 2:
liste=okt(zahl,liste)
if wahl == 3:
liste=hexa(zahl,liste)
ausgabe(wahl,zahl,liste)
raw_input(" weiter mit <Enter> ...")
print "\n\t!! Programmende!!"
def menue():
print """
**************************************
* Stellenwertsystem Umrechner *
**************************************
"""
print "<1> Dezimal -> Dual"
print "<2> Dezimal -> Oktal"
print "<3> Dezimal -> Hexadezimal"
print "<4> Programmende"
return input("Treffen Sie bitte Ihre Wahl (1-4)? ")
def ausgabe(wahl, zahl,liste):
print " ___________________ Ergebnis der Berechnung ________________\n"
if wahl == 1:
print "\tDez -> Dual"
if wahl == 2:
print "\tDez -> Oktal"
if wahl == 3:
print "\tDez -> Hexa"
print "\t",zahl ,"->",liste
print "\t\t________________________________"
def dual(z,li):
z=1
li.insert(0,z)
z=0
li.insert(0,z)
z=0
li.insert(0,z)
return li
def okt(z,li):
z=7
li.insert(0,z)
z=5
li.insert(0,z)
z=6
li.insert(0,z)
return li
def hexa(z,li):
z="F"
li.insert(0,z)
z=5
li.insert(0,z)
z="B"
li.insert(0,z)
return li
main()
Code: Alles auswählen