Programming Examples

Python program to read prices of 5 items in a list and then display sum of all the prices product of all the prices and find the average


Python program to read prices of 5 items in a list and then display sum of all the prices, product of all the prices and find the average

Solution

items=[]
prod=1
for i in range(5):
	print ("Enter price for item { } : ".format(i+1))
	p=int(input())
	items.append(p)
for j in range(len(items)):
	print("Price for item { } = Rs. { }".format(j+1,items[j]))
	prod = prod * items[j]
print("Sum of all prices = Rs.", sum(items))
print("Product of all prices = Rs.", prod)
print("Average of all prices = Rs.",sum(items)/len(items))
Output

Enter price for item 1 :

5

Enter price for item 2 :

10

Enter price for item 3 :

15

Enter price for item 4 :

20

Enter price for item 5 :

25

Price for item 1 = Rs. 5

Price for item 2 = Rs. 10

Price for item 3 = Rs. 15

Price for item 4 = Rs. 20

Price for item 5 = Rs. 25

Sum of all prices = Rs. 75

Product of all prices = Rs. 375000

Average of all prices = Rs. 15.0

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad