Computer Science, asked by saurabhsinghchamyal, 9 months ago

write a Python program that asks the user for 7 numbers. then print the total of these entries the number of positive entries, the number of entries equal to zero and the number of negative entries​

Answers

Answered by shahkhushee700
1

Explanation:

Count positive and negative numbers from given list using for loop

Iterate each element in the list using for loop and check if num >= 0, the condition to check positive numbers. If the condition satisfies, then increase pos_count else increase neg_count.

# Python program to count positive and negative numbers in a List

# list of numbers

list1 = [10, -21, 4, -45, 66, -93, 1]

pos_count, neg_count = 0, 0

# iterating each number in list

for num in list1:

# checking condition

if num >= 0:

pos_count += 1

else:

neg_count += 1

print("Positive numbers in the list: ", pos_count)

print("Negative numbers in the list: ", neg_count)

Similar questions