Write a program that reads an unspecified number of integers, determines how many positive
and negative values have been read, and computes the total and average of the input values (not
counting the zero). The program ends with the input 0. Display the average as a floating-point number
sum1 = 0
count_pos = 0
count_neg = 0
while (True):
i = float(input("Enter an integer (0 to stop): "))
if i == 0:
break
sum1 += i
if i > 0:
count_pos += 1
elif i < 0:
count_neg += 1
print("The total number of positive numbers: ", count_pos)
print("The total number of negative numbers: ", count_neg)
print("The total sum: ", sum1)
Comments
Leave a comment