Write a program to enter the numbers till the user wants and at the end it should display the count of positive, negative and zeros entered.
Source Code
positive_count = 0
negative_count = 0
zero_count = 0
choice = 'Y'
while choice == 'Y' or choice == 'y':
num = int(input("Enter a number: "))
if num == 0:
zero_count += 1
elif num > 0:
positive_count += 1
else:
negative_count += 1
choice = input("Do you wish to continue (y/n)?: ")
print("Positive numbers:", positive_count, ", Negative numbers:", negative_count, ", Zeros:", zero_count)
Output
Enter a number: 5
Do you wish to continue (y/n)?: y
Enter a number: -2
Do you wish to continue (y/n)?: y
Enter a number: 0
Do you wish to continue (y/n)?: y
Enter a number: 8
Do you wish to continue (y/n)?: n
Positive numbers: 2 , Negative numbers: 1 , Zeros: 1