Respuesta :
Answer:
count_p = 0
count_n = 0
total = 0
while True:
number = int(input("Enter an integer, the input ends if it is 0: "))
if number == 0:
break
else:
total += number
if number > 0:
count_p += 1
elif number < 0:
count_n += 1
print("The number of positives is: " + str(count_p))
print("The number of negatives is: " + str(count_n))
print("The total is: " + str(total))
print("The average is: " + str(total / (count_p + count_n)))
Explanation:
Initialize the variables, count_p represens the number of positives, count_n represents the number of negatives, and total represents the total of the numbers
Create a while loop iterates until the user enters 0. If the number is not 0, then add it to the total. If the number is greater than 0, increase count_p by 1. If the number is smaller than 0, increase count_n by 1.
When the loop is done, print the count_p, count_n, total, and average
The program which displays the number of positive and negative values inputted. The program written in python 3 goes thus :
pos_val = 0
#initialize a variable to hold the number of positive values
neg_val = 0
#initialize a variable to hold the number of negative values
sum = 0
#initialize a variable to hold the sum of all values
while True :
#A while loop is initiated
val = int(input("Enter integer values except 0 : "))
#prompts user for inputs
if val == 0 :
#checks if inputted value is 0
break
#if True end the program
else :
#otherwise
sum +=val
#add the value to the sum variable
if val > 0 :
#checks if value is greater than 0
pos_val += 1
#if true increase positive value counts by 1
else :
neg_val += 1
#if otherwise, increase negative value counts by 1
freq = float(pos_val + neg_val )
#calculates total number of values
print('The number of positive values is = ', pos_val)
#display number of positive values
print('The number of negative values is = ', neg_val)
#display number of negative values
print('The total sum of values is = ', sum)#display the total sum
print('The average is {:.2f}' .format((sum))
#display the average of the inputs
Learn more : https://brainly.com/question/19323897

