- times_ten
a) Write a value-returning function called times_ten that prompts the user to enter an integer and returns the input value times 10. Print the product from the main function to check for correctness. Enter a letter instead of an integer and notice the exception that’s raised.
b) In the times_ten function, move the enter integer prompt to a try block. Add a corresponding except for block
that catches the exception you identified in step a and print an appropriate error message. - Simple exception handling
Type the python code below in the main function and add appropriate exception logic. You should handle
divide by zero and non-numeric errors.
def validate():
for i in range(3):
x = int(input(‘Enter a number: ‘))
y = int(input(‘Enter a second number: ‘))
print(x, ‘/’, y, ‘=’, x/y) - Updated Customer Payments
Modify the program you wrote in Lab 8b to:
- Enter the file name and validate it exists.
- Confirm the payment amount on each record is a floating-point number.
- Include a general exception block to handle any other errors
Display an appropriate error message if either of these edits fails.