In: Computer Science
Design a Python program with a While loop that lets the user enter a number. The number should be multiplied by 10 and the result
stored in a variable named "product". The loop should repeat as long as the product variable < 10. Anything not completely obvious to a newbie should be commented on as in line comments. Should be modulated and repeatable as well as there should be an invocation of the main routine at the end of the program.
Grading Rubrick
Program Compiles Cleanly | syntax errors |
25 pts | -5 per error |
Program runs without runtime errors ( validation) | run-time errors |
25 pts | -5 per error |
Program give correct answers | Logic errors |
30 pts | -5 per error |
Program is repeatable | Not repeatable |
5 pts | -5 pts |
Program is well modularized | Barely Modularized |
10 pts | - 5 pts |
Documented Well | Documented Some |
5 pts | - 3 pts |
Something Cool (but relevant) beyond strict requirements | Something extra |
5 pts | + 3 pts |
Best possible grade : 105 |
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions. Thank You! =========================================================================== # function prompts for a number until a valid number is entered # and returns the number def getValidNumber(): ''' :return: a valid number ''' while True: try: val = input('Enter a number: ') val = float(val) return val except: print('Error: {} is not a number'.format(val)) def main(): num = getValidNumber() product = num * 10 print('{} times 10 is {}'.format(num, product)) while product < 10: num = getValidNumber() product = num * 10 print('{} times 10 is {}'.format(num, product)) print('Good Bye!') main()
==================================================================