|
1 |
| - |
| 1 | +""" |
| 2 | +4. Roman Numerals |
| 3 | +Write a program that prompts the user to enter a number within the range of |
| 4 | +1 through 10. |
| 5 | +The program should display the Roman numeral version of that number. |
| 6 | +If the number is outside the range of 1 through 10, the program should display |
| 7 | +an error message. |
| 8 | +The following table shows the Roman numerals for the numbers 1 through 10: |
| 9 | +Number - Roman Numeral |
| 10 | +1 -------------------- I |
| 11 | +2 -------------------- II |
| 12 | +3 -------------------- III |
| 13 | +4 -------------------- IV |
| 14 | +5 -------------------- V |
| 15 | +6 -------------------- VI |
| 16 | +7 -------------------- VII |
| 17 | +8 -------------------- VIII |
| 18 | +9 -------------------- IX |
| 19 | +10 ------------------ X |
| 20 | +Reference: |
| 21 | +(1) Starting out with Python, Third Edition, Tony Gaddis Chapter 3 |
| 22 | +(2) https://youtu.be/lV-EUUOvKB0 |
| 23 | +""" |
| 24 | +# Get User Input(a number within the range of 1 through 10. ) |
| 25 | +# Convert User input to int |
| 26 | +number = int(input("Please Enter a number within the range of 1 through 10 : ")) |
| 27 | +# check all the conditions |
| 28 | +if number == 1: |
| 29 | + print(f"the Roman numeral version of {number} is I") |
| 30 | +elif number == 2: |
| 31 | + print(f"the Roman numeral version of {number} is II") |
| 32 | +elif number == 3: |
| 33 | + print(f"the Roman numeral version of {number} is III") |
| 34 | +elif number == 4: |
| 35 | + print(f"the Roman numeral version of {number} is IV") |
| 36 | +elif number == 5: |
| 37 | + print(f"the Roman numeral version of {number} is V") |
| 38 | +elif number == 6: |
| 39 | + print(f"the Roman numeral version of {number} is VI") |
| 40 | +elif number == 7: |
| 41 | + print(f"the Roman numeral version of {number} is VII") |
| 42 | +elif number == 8: |
| 43 | + print(f"the Roman numeral version of {number} is VIII") |
| 44 | +elif number == 9: |
| 45 | + print(f"the Roman numeral version of {number} is IX") |
| 46 | +elif number == 10: |
| 47 | + print(f"the Roman numeral version of {number} is X") |
| 48 | +else: |
| 49 | + print("Error ! : Please Enter a number in the range of 1 through 10") |
| 50 | +""" |
| 51 | +this Question can be solve with loop very easy but am flowing the book |
| 52 | +and in chapter 3 is all about if condition |
| 53 | +""" |
0 commit comments