Computer Science, asked by kashifazmi38, 2 months ago

Write a program to accept 'n' integers and nd out :

i. number of positive numbers

ii. number of negative numbers

iii. sum of positive number​

Answers

Answered by Equestriadash
9

#initializing the number of integers

n = int(input("Enter the number of integers you'd like to enter: "))

#initializing a list for the integers

l = list()

print()

#obtaining the list of integers

for i in range(n):

   x = int(input("Enter the integer: "))

   l.append(x)

   print()

print()

#counting the number of positive integers

cp = 0

for i in l:

   if i >= 1:

       cp = cp + 1

print("There are", cp, "positive integers in the list.")

#counting the number of negative integers

cn = 0

for i in l:

   if i < 0:

       cn = cn + 1

print("There are", cn, "negative integers in the list.")

#printing the sum of the positive integers

s = 0

for i in l:

   if i >= 1:

       s = s + i

print(s, "is the sum of the positive integers.")

Similar questions