# initialize variables
total_height = 0
num_students = 25
# loop over each student and prompt the user to enter their height
for i in range(num_students):
height = float(input(f"Enter height of student {i+1}: "))
total_height += height
# calculate the average height
average_height = total_height / num_students
# display the average height
print(f"The average height of the class is {average_height:.2f}")
Copyright © 2025 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
# initialize variables
total_height = 0
num_students = 25
# loop over each student and prompt the user to enter their height
for i in range(num_students):
height = float(input(f"Enter height of student {i+1}: "))
total_height += height
# calculate the average height
average_height = total_height / num_students
# display the average height
print(f"The average height of the class is {average_height:.2f}")