Question: Using Python, write a program that asks the user to input a set of floating-point values. Enter a number, or 2 non-numbers to quit:

Using Python, write a program that asks the user to input a set of floating-point values.

"Enter a number, or 2 non-numbers to quit: "

"Enter a number, or another non-number to quit: "

When user enters a value that is not a number, give the user a second chance to enter the value. If user enters 2 non - numbers in a row, exit the program. Add all correctly specified values and print the sum when the user is done entering data.

"The total is xx "

Where xx is the result of the sum. (Use exception handling to detect improper inputs.)

Below is an example of the output of the program with inputs 10,20,x,10,x,x

Enter a number, or 2 non-numbers to quit: 10

Enter a number, or 2 non-numbers to quit: 20

Enter a number, or 2 non-numbers to quit: x

Enter a number, or another non-number to quit: 10

Enter a number, or 2 non-numbers to quit: x

Enter a number, or another non-number to quit: x

The total is 40.0

USE TRY AND EXCEPT

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!