Using Python, have your program do the following, using loops (no recursion)

1. Have the user repeatedly enter integers until they enter a negative number. At that point stop inputting and proceed to the output described in step two. Note: The negative number that terminates the input is not included in any of these results.
2. When the input is done, display the following if there was at least one valid (non -negative) number entered:

(a) The sum of the numbers entered in that loop
(b) How many numbers were entered
(c) The average of those numbers to two places (avoid integer division.)
(d) The lowest number input
(e) The highest number input

If there were no (valid) numbers entered, make sure your code displays the message "no valid numbers entered" (and avoids dividing by 0) instead of displaying a - e below.

Respuesta :

Answer:

Explanation:

# taking first number

low = int(input("Enter a number: "))

# if that is valid

if low >= 0:

 

# considering it as high, sum and input

high = low

sum = low

count = 1

inp = low

 

# breaking if negative number is entered

while True:

 

# taking user input of numbers

inp = int(input("Enter a number: "))

 

if inp >= 0:

 

# adding it to sum

sum = sum + inp

 

# checking for low

if low > inp:

low = inp

 

# checking for high

if high < inp:

high = inp

 

# tracking count

count = count + 1

else:

break

 

# printing output

print("\nSum =",sum)

print("count =",count)

print("Average =",round(sum/float(count),2))

print("Lowest =",low)

print("Highest =",high)

 

# no valid numbers

else:

print("no valid numbers entered")

ACCESS MORE