Предмет: Информатика, автор: abdyldabek

Python.Идет отбор учеников 8-го класса для записи в бас-
кетбольную секцию с учетом их роста. Всего в отборе приня-
ли участие N (130≤рост учащихся≤200) учащихся. Из них
были приняты в секцию ребята с ростом выше K сантиметров.
Сколько учащихся принято в секцию и какой рост у самого
высокого ученика? Рост учащихся вводится последовательно.

Ответы

Автор ответа: hagadf
1

# Input the number of students and the height threshold

n = int(input("Enter the number of students: "))

k = int(input("Enter the height threshold (in cm): "))

# Initialize a list to store the heights of all students

heights = []

# Initialize a variable to store the number of students accepted

num_accepted = 0

# Initialize a variable to store the height of the tallest student

tallest_height = 0

# Input the heights of all students

for i in range(n):

   height = int(input("Enter the height of student {} (in cm): ".format(i+1)))

   heights.append(height)

# Iterate through the list of student heights and check if each height is greater than the threshold K

for height in heights:

   if height > k:

       num_accepted += 1

       # Check if the current student's height is greater than the current tallest student's height

       if height > tallest_height:

           tallest_height = height

# Output the number of students accepted and the height of the tallest student

print("Number of students accepted: {}".format(num_accepted))

print("Height of the tallest student: {}cm".format(tallest_height))


N1gerunday0: это правильно?
lcchtbk: нет конечно
kurtovarman: правильно?
hagadf: Правильно все)
Похожие вопросы
Предмет: Алгебра, автор: kovalchuk2843