Question:
Write a python script to display elements of list and also count and print total +ve elements in the list.
n=[1,12,-33,14,-25,16,47,-98] p=0 for i in n: print(i) if i>0: p=p+1 print("Total +ve elements = ",p)
Output:
1
12
-33
14
-25
16
47
-98
Total +ve elements = 5
Question:
Write a python script to display elements of list and also count and print total -ve elements in the list.
n=[1,12,-33,14,-25,16,47,-98] p=0 for i in n: print(i) if i<0: p=p+1 print("Total -ve elements = ",p)
Output:
1
12
-33
14
-25
16
47
-98
Total -ve elements = 3
Question:
Write a python script to display elements of list and also count and print
(a) total +ve elements in the list.
(b) total -ve elements in the list.
n=[1,12,-33,14,-25,16,47,-98] po=0 ne=0 for i in n: print(i) if i>0: po=po+1 if i<0: ne=ne+1 print("Total +ve elements = ",po) print("Total -ve elements = ",ne)
Output:
1
12
-33
14
-25
16
47
-98
Total +ve elements = 5
Total -ve elements = 3