09 Prepare : Checkpoint A - Exceptions
After completing (or while completing) the preparation material for this week, complete the following exercise.
Overview
This checkpoint is intended to help you practice the syntax of exceptions.
Instructions
Write a program that prompts the user for a number and then displays back that number multiplied by 2. Your program should continue to reprompt them as long as they enter a string. To accomplish this, adhere to the following guidelines:
Your code should assume that the value entered is a valid number and then catch an exception if it's not.
If an exception is caught, your program should display the text, "The value entered is not valid" and then prompt again.
It should continue prompting them as long as the value entered is not a number.
Sample Output
The following is an example of output for this program:
Enter a number: 3
The result is: 6
And here is another example:
Enter a number: word
The value entered is not valid
Enter a number: tacos
The value entered is not valid
Enter a number: something else
The value entered is not valid
Enter a number: 10
The result is: 20
Testbed
An auto-grading testbed script is provided for you to help evaluate your program. This same testbed script will be used to grade your program. It is pass/fail, so your program must pass the testbed completely for you to receive credit for this assignment. You may run the testbed as many times as you like.
You must use exceptions for this program in order to receive credit.
Helpful commands
testBed cs241/check09a check09a.py
submit check09a.py