Question
Data Entry (Python) In this lab you will write a program that prompts the user to enter a sequence of positive integers, terminated by entering
Data Entry (Python)
In this lab you will write a program that prompts the user to enter a sequence of positive integers, terminated by entering the sentinel value -1.
As the numbers are entered, the program will keep track of the current minimum and maximum values seen. Once the loop has terminated, the program will compute the average value, and then print the results.
If the user immediately enters -1, simply output the message No values entered.
Hints
1) Initialize minimum and maximum variables to None; initialize total and count variables to 0.
2) Get the first input value before entering the loop.
3) Use a while loop, testing for the sentinel value.
4) Inside the body of the loop, if minimum (or maximum) is None it signifies that it is the first iteration, so set the tracking values, otherwise update the tracking values.
5) Don't forget to re-prompt for the next number, at the bottom of the loop body.
Sample Runs
Enter a sequence of positive integers (-1 to end) ... > 24 > 19 > 6 > 8 > -1 Values entered: 4 Minimum: 6 Maximum: 24 Average: 14.25
Enter a sequence of positive integers (-1 to end) ... > 200 > -1 Values entered: 1 Minimum: 200 Maximum: 200 Average: 200.0
Enter a sequence of positive integers (-1 to end) ... > -1 No values entered
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started