## Python Exercise 2, Part 1:

In this Python exercise, write a Python program that will compute the factorial of a given number. The given number is entered with the user input between 1 and 10. Also, the result of this Python program should result with a print on a single line.

*Note: This exercise is completed in Python 3.7*

**Solution ****Python Exercise 2, Part 1**

**Python Code Input:**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
num = int(input("\nEnter a number between 1 and 10: ")) try: x = int(num) print(f"\nThe number entered is {x}.") except ValueError: print(f"\nIn order to convert a number to an integer, the value entered must be a number. You entered {num} .") def fact(x): if x == 0: return 1 return x * fact(x - 1) print(f"\nThe result of {x} * fact({x} - 1) is", (fact(x))) |

**User Input:**

1 |
Enter a number between 1 and 10: 5 |

**Python Code Output:**

1 2 3 |
The number entered is 5. The result of 5 * fact(5 - 1) is 120 |