by CodeChum Admin
There are different kinds of numbers, but among them all, the most commonly used numbers in our daily lives are those positive ones. So, I only want you to count all the positive numbers from the 4 outputted values and print out the result.
Go and search for the positive ones among these four!
Input
1. First number
2. Second number
3. Third number
4. Fourth number
Output
The first four lines will contain message prompts to input the four numbers.
The last line contains the total count of all the positive numbers.
Enter·the·first·number:·2
Enter·the·second·number:·-4
Enter·the·third·number:·3.6
Enter·the·fourth·number:·1
Count·of·positives·=·3
count = 0
x = float(input("Enter the first number: "))
if x > 0:
count += 1
x = float(input("Enter the second number: "))
if x > 0:
count += 1
x = float(input("Enter the third number: "))
if x > 0:
count += 1
x = float(input("Enter the fourth number: "))
if x > 0:
count += 1
print('Count of positives =', count
Comments
Leave a comment