Вопрос задан 31.10.2023 в 04:29. Предмет Информатика. Спрашивает Калашников Темирлан.

ЗАДАЧА Три толстяка решили поспорить: кто из них самый тяжелый. После взвешивания оказалось, что

их масса соответственно M1, M2 и M3 килограмм. Считается, что масса толстяка должна быть не менее 94 и не более 727 килограмм. Помогите определить массу самого тяжелого из них, либо выяснить, что была допущена ошибка при взвешивании. Я где-то допустила ошибку m1,m2,m3= map(int,input().split()) if 94>m1&m2&m3 or 727 print("Error") if m1m3 : print(m2) else: m1m2 print(m3) if m2m3: print(m1) else: m2==m3==m1 print(m3)
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Токтасынов Азамат.

Ответ:

Вот. Вообще всё было неправильно, кроме 1 строчки. Нельзя в условиях просто писать две переменные.

Объяснение:

m1,m2,m3= map(int,input("Введите массы трёх толстяков, разделённые пробелами. ").split())

if 94 > m1 or 94 > m2 or 94 > m3 or 727 < m1 or 727 < m2 or 727 <m3 :

   print("Error")

elif m1 > m2 and m1 >  m3:

   print("m1 = ", m1)

elif m2 > m1 and m2 > m3:

   print("m2 = ", m2)

elif m3 > m1 and m3 > m2:

   print("m3 = ", m3)

else:

   print("m2==m3==m1 = ", m1)

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

To solve the problem, we need to determine the mass of the heaviest person among the three. Let's analyze the given code and understand how it works.

The code snippet provided is written in Python and attempts to solve the problem. Here's a breakdown of the code:

```python m1, m2, m3 = map(int, input().split()) if 94 > m1 and m2 and m3 or m1 > 727: print("Error") if m1 > m3: print(m2) else: m1 > m2 print(m3) if m2 > m3: print(m1) else: m2 == m3 == m1 print(m3) ```

The code takes three inputs, `m1`, `m2`, and `m3`, which represent the masses of the three individuals. It then checks if any of the masses are less than 94 or greater than 727. If this condition is met, it prints "Error".

Next, the code compares the masses of the individuals to determine the heaviest person. It first checks if `m1` is greater than `m3`. If true, it prints `m2`. Otherwise, it checks if `m1` is greater than `m2`. If true, it prints `m3`. If none of these conditions are met, it means that all three masses are equal, and it prints `m3`.

While the code attempts to solve the problem, there are a few issues with it. Firstly, the condition `94 > m1 and m2 and m3 or m1 > 727` is incorrect. It should be `94 > m1 or m2 or m3 or m1 > 727` to check if any of the masses fall outside the valid range. Additionally, the code has syntax errors due to incorrect indentation.

To fix the code and solve the problem correctly, you can use the following modified code:

```python m1, m2, m3 = map(int, input().split()) if 94 > m1 or m2 or m3 or m1 > 727: print("Error") elif m1 > m2 and m1 > m3: print(m1) elif m2 > m3: print(m2) else: print(m3) ```

This code correctly checks if any of the masses fall outside the valid range and prints "Error" if that is the case. It then compares the masses to determine the heaviest person and prints the corresponding mass.

Remember to provide the input values when running the code to get the desired output.

0 0

Похожие вопросы

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос