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

Известен рост трех учеников, найти средний рост, выяснить кто самый высокий и самый низкий.

In python please: if/else, условные операторы

Ответы

Автор ответа: pupkinll2016
2

Ответ:

# Ввод роста каждого из трех учеников

height1 = float(input("Введите рост первого ученика: "))

height2 = float(input("Введите рост второго ученика: "))

height3 = float(input("Введите рост третьего ученика: "))

# Находим средний рост

average_height = (height1 + height2 + height3) / 3

# Определяем самого высокого ученика

if height1 >= height2 and height1 >= height3:

tallest_student = "первый ученик"

elif height2 >= height1 and height2 >= height3:

tallest_student = "второй ученик"

else:

tallest_student = "третий ученик"

# Определяем самого низкого ученика

if height1 <= height2 and height1 <= height3:

shortest_student = "первый ученик"

elif height2 <= height1 and height2 <= height3:

shortest_student = "второй ученик"

else:

shortest_student = "третий ученик"

# Выводим результаты

print("Средний рост:", average_height)

print("Самый высокий ученик:", tallest_student)

print("Самый низкий ученик:", shortest_student)


pupkinll2016: понял
poilwid: так это пример
pupkinll2016: понял
poilwid: как в ответе написано, нас так не обучали
pupkinll2016: ты хочешь чтобы ты с клавиатуры вводил рост
poilwid: да
pupkinll2016: исправил
pupkinll2016: сойдёт?
poilwid: ща посмотрю
pupkinll2016: Окей
Интересные вопросы
Предмет: Литература, автор: anastasiademcisin5
Предмет: Английский язык, автор: niky29
1.Imagine! Next year my Grandpa.. lectures at the University for 40 years already?
a) will be giving
c) Will have giver
• Wilsive
d) will have been giving
2. Can you send me the results as soon as you ...
a) hear anything
b) are hearing anything
c) will have heard anything
d) will hear anything
3.I bring you some coffee?
a) Will
b) Do
c) Would
d) Shall

c
=
4. By the next week we will .. at our project for three months already but the results are not
c) be working
b) have worked
d) have been working
5. They really had a wonderful time in Brighton. How long ... they ... there?
a) had... been staying
c) were ... staying
b) did.. stay
d) have
.. been staying
6. I... a doctor immediately. He is running a high temperature.
a) will call
c) call
b) am going to call
d) am calling
7. If we don't hurry, the party will... before we get there.
a) finish
c) be finishing
b) have finished
d) have been finishing
8. Maggie sipped her coffee and pulled a face. She thought it... horrible.
a was tasted
c) was tasting
b) tastes
d) tasted
9. When I was speaking with her on the phone I realized that something unusual ..
a) had happened
c) had been happening
15 naDDening
d) nas happened
10. According to the latest forecast, the tunnel... next year.
a Will have been 11shed
c) is finishing
b) will be finished
d) will finish
11. Since then I... my job several times.
a) changed
Ci changs
b have changed
d) had changed
12. We are going for our holidays to Spain. This time tomorrow we'll... the warm sea and sunshine.
a) enjoy
b) have enjoyed
d) have been enjoyed
13. The lights went off and the orchestra... playing.
a) started
c) was starting
bhad started
d) had been starting
14. Jane... a dark-blue suit when she came for the interview.
a) wore
c) was wearing
b) had wom
d) had been wearing
15. My daughter... taking music lessons but soon gave it up.
a) began
c) was beginning
b) had began
d) had been beginning