Question:
Write a python script to display elements of list and also display sum of all the elements.
n=[1,2,3,4,5,6,7]
s=0
for i in n:
print(i)
s=s+i
print("Sum = ",s)
Output:
1
2
3
4
5
6
7
Sum = 28
Question:
Write a python script to display elements of list and also display product of all the elements.
n=[1,2,3,4,5,6,7]
p=1
for i in n:
print(i)
p=p*i
print("Product = ",p)
Output:
1
2
3
4
5
6
7
Product = 5040
Question:
Write a python script to display elements of list and also display:
(a). sum of all the elements.
(b). average of all the elements.
n=[1,12,33,14,25,16,7]
s=0
for i in n:
print(i)
s=s+i
print("Sum = ",s)
t=len(n)
av=s/t
print("Average = ",av)
Output:
1
12
33
14
25
16
7
Sum = 108
Average = 15.428571428571429




