test1
This commit is contained in:
28
operators_21.py
Normal file
28
operators_21.py
Normal file
@@ -0,0 +1,28 @@
|
||||
n = int(input("Введите количество учеников: "))
|
||||
|
||||
boys_total = 0
|
||||
boys_count = 0
|
||||
girls_total = 0
|
||||
girls_count = 0
|
||||
|
||||
for i in range(n):
|
||||
height = int(input(f"Введите рост ученика {i + 1} (для мальчиков - отрицательное): "))
|
||||
|
||||
if height < 0:
|
||||
boys_total += -height
|
||||
boys_count += 1
|
||||
else:
|
||||
girls_total += height
|
||||
girls_count += 1
|
||||
|
||||
if boys_count > 0:
|
||||
avg_boys = boys_total / boys_count
|
||||
print(f"Средний рост мальчиков: {avg_boys:.1f} см")
|
||||
else:
|
||||
print("Мальчиков нет")
|
||||
|
||||
if girls_count > 0:
|
||||
avg_girls = girls_total / girls_count
|
||||
print(f"Средний рост девочек: {avg_girls:.1f} см")
|
||||
else:
|
||||
print("Девочек нет")
|
||||
Reference in New Issue
Block a user