Create .py code allowing use input float # until sentinel val of 0 is inputted. When zero is entered, the program with end.
Should out put the following:
Amount of number (#) user input, Sum of # imputted, Avg. of the numbers imputted, Lowest # entered, and Highest # entered.
Python
#!/usr/bin/python
count = 0
sum = 0.00
average = 0.00
lowest_value = 0.00
highest_value = 0.00
input_values = float(raw_input("Enter input value:"))
while( input_values >0 ):
if( input_values > highest_value ): # check if the
entered number is greater than the value in highest_value variable,
if so store it in highest_value variable
highest_value = input_values
elif( input_values < lowest_value and lowest_value
> 0): # check if the entered number is less than the value in
lowest_value variable, if so store in lowest_value variable. Also
check if the lowest_value is greater than 0.
lowest_value = input_values
elif( lowest_value ==0 ): #If the lowest_value is 0
then store the value in lowest_value variable
lowest_value = input_values
count +=1
sum = sum + input_values
input_values = float(raw_input("Enter input
value:"))
average = sum/count
print " The number of user inputs are: " , count , " \n The sum of
input values is: " , sum , " \n The Average of use input values is
: " , average , " \n The highest entered by the user is : " ,
highest_value , " \n The lowest value entered by the user is : " ,
lowest_value
Get Answers For Free
Most questions answered within 1 hours.