2 תשובות
אציע לך דרך נוספת לעשות את זה בהתחשב שהממוצע הוא של כל הגבהים
pupils = int(input("enter the pupils count: "))
heights = []
underh = 0
avg = 0
for i in range(0 , pupils):
height = float(input("enter this pupil's height: "))
heights.append(height)
for i in range(len(heights)):
if heights[i] < 1.65:
underh += 1
print("the amount of pupils that under 1.65 are:" , underh)
for i in range(len(heights)):
avg += heights[i]
print("heights average is" , heights[i] / 2 , "meters")
pupils = int(input("enter the pupils count: "))
heights = []
underh = 0
avg = 0
for i in range(0 , pupils):
height = float(input("enter this pupil's height: "))
heights.append(height)
for i in range(len(heights)):
if heights[i] < 1.65:
underh += 1
print("the amount of pupils that under 1.65 are:" , underh)
for i in range(len(heights)):
avg += heights[i]
print("heights average is" , heights[i] / 2 , "meters")
טיפה ארוך יותר, אבל התוצאה בדיוק אותה תוצאה :)
באותו הנושא: