Question: Write a program that repeatedly reads integers from the user until the user enters the word 'stop' (this is called a sentinel value). When the
Write a program that repeatedly reads integers from the user until the user enters the word 'stop' (this is called a sentinel value). When the user enters the sentinel value, output the following statistics about the sequence of integers: sum, average, sum of even numbers, and the largest number.
For example:
Enter a sequence of integers. Enter 'stop' to exit.
> 1
> 3
> 1
> 3
> 4
> 9
> 3
> stop
Sum: 24
Average: 3.4285714285714284
Even Sum: 4
Largest number: 9
Hint: don't try to store every value, instead keep track of the relevant statistics with each new number (e.g. add up each number as they're entered to determine the sum).
use Python
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
