Python 3.4 - Roman Numerals

This program prints out the equivalent roman numeral:

roman = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X']

num_input = ''
while num_input != 'q':
    print("\n[1] Enter a number (1-10) to convert into a roman numeral.")
    print('\npress q to exit')

    num_input = input("\nEnter your number: ")

    if num_input == '1':
        print('\nThat is the roman numeral: ' + roman[0])
    elif num_input == '2':
        print('\nThat is the roman numeral: ' + roman[1])
    elif num_input == '3':
        print('\nThat is the roman numeral: ' + roman[2])
    elif num_input == '4':
        print('\nThat is the roman numeral: ' + roman[3])
    elif num_input == '5':
        print('\nThat is the roman numeral: ' + roman[4])
    elif num_input == '6':
        print('\nThat is the roman numeral: ' + roman[5])
    elif num_input == '7':
        print('\nThat is the roman numeral: ' + roman[6])
    elif num_input == '8':
        print('\nThat is the roman numeral: ' + roman[7])
    elif num_input == '9':
        print('\nThat is the roman numeral: ' + roman[8])
    elif num_input == '10':
        print('\nThat is the roman numeral: ' + roman[9])
    elif num_input == 'q':
        print('\nHave a good day.')
    else:
        print("\nThat won't work.")

/Users/mattfassnacht/PycharmProjects/untitled8/venv/bin/python /Users/mattfassnacht/PycharmProjects/untitled8/math.py

[1] Enter a number (1-10) to convert into a roman numeral.

press q to exit

Enter your number: 1

That is the roman numeral: I

[1] Enter a number (1-10) to convert into a roman numeral.

press q to exit

Enter your number: 3

That is the roman numeral: III

[1] Enter a number (1-10) to convert into a roman numeral.

press q to exit

Enter your number: 9

That is the roman numeral: IX

[1] Enter a number (1-10) to convert into a roman numeral.

press q to exit

Enter your number: f

That won't work.

[1] Enter a number (1-10) to convert into a roman numeral.

press q to exit

Enter your number: q

Have a good day.

Process finished with exit code 0

Comments

Popular posts from this blog

Pyhton 3.4 - Continue

Conversations Ongoing: Valuing Modernization in Early European History

Conversations Ongoing: A Bunch of Amateurs