In: Computer Science
Averaging measurements: Use python 3 to write this program
Assume that someone has collected a set of measurements and wants some statistical data about them. Write a program that asks a user for measurements and prints the average, the maximum, and the minimum measurement. Users should be allowed to enter as many measurements as they want, until entering a negative measurement. The negative measurement should not be processed, but is just used to indicate that the user has finished entering measurements. [Note: do not use a list to store the measurements.]
Note: Complete without using import sys. Only use simple for and while loops and if else statements.
HOPE THIS
ANSWER SATISFIES YOUR QUERY. IF I MISSED SOMETHING PLEASE DO
MENTION IN THE COMMENTS AND ALSO PLEASE RATE THE ANSWER. I HAVE
ALSO ATTACHED THE SCREENSHOT OF THE CODE ALONG WITH THE OUTPUT FOR
BETTER UNDERSTANDING.
THANKS
*********CODE STARTS HERE***************
sum1 = 0
count = 0
maxx = 0
minn = 100000000
input1 = 1 #initial value of input > 0
while input1>0:
input1 = int(input())
if input1<0: #if input is negative breaks out of loop
break
sum1 = sum1+ input1 #sum is added on every iteration
count = count+1 #count is added on every iteration
if input1>maxx:
maxx = input1 #max is calculated
if input1<minn:
minn = input1 #min is calculated
print("Average is: " , sum1/count)
print("maximum is ", maxx)
print("Minimum is ", minn)
**********CODE ENDS HERE****************