LU06.L07: Römische Zahlzeichen

roman.py
def main():
    numerals = ['M', 'D', 'C', 'L', 'X', 'V', 'I']
    decimals = [1000, 500, 100, 50, 10, 5, 1]
    count = 0
    result = ''
 
    number = int(input('Dezimalzahl > '))
    while number > 0:
        if (number >= decimals[count]):
            result += numerals[count]
            number = number - decimals[count]
        else:
            count = count + 1
    print(result)
    return numerals, decimals
 
 
if __name__ == '__main__':
    main()

Kevin Maurizi, Marcel Suter

  • modul/m319/learningunits/lu06/loesungen/roemisch.txt
  • Zuletzt geändert: 2024/03/28 14:07
  • von 127.0.0.1