Answer to Question #92558 in Python for Sanjay Sekhon

Question #92558
Mr. John wants to calculate the total marks and average marks for his class of 5 students
for Maths, Science and Geography (for each subject). Write down coding that will help
him to accomplish this task using while loop
1
Expert's answer
2019-08-13T02:40:56-0400
math = 0
sciense = 0
geography = 0

i = 0
while i < 5:
  math += float(input("Enter Math mark for student " + str(i + 1)+": "))
  sciense += float(input("Enter Science mark for student " + str(i + 1)+": "))
  geography += float(input("Enter Geugraphy mark for student " + str(i + 1)+": "))
  i = i + 1

print()
print("Total Math mark: " + str(math) + ", average: " + str(math/i))
print("Total Science mark: " + str(sciense) + ", average: " + str(sciense/i))
print("Total Geography mark: " + str(geography) + ", average: " + str(geography/i))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS