Добавил кода

This commit is contained in:
dr_domi
2026-05-02 19:23:00 +03:00
parent 2f4528f60e
commit e0fb94d299
+18 -7
View File
@@ -1,8 +1,19 @@
def calculate(height, wight):
result = wight / height ^ 2
return result
def calculate(height, weight):
result = weight / (height ** 2)
return round(result, 2)
def user_input_check(height, wight):
if height.isdigit() and wight.isdigit():
if height != 0 and wight != 0:
return True
def user_input_check(height, weight):
# Проверка, что введённые значения — числа
if not (height.replace('.', '', 1).isdigit() and weight.replace('.', '', 1).isdigit()):
return "Ошибка: введите корректные числовые значения."
height = float(height)
weight = float(weight)
if height <= 0 or height > 3:
return "Ошибка ввода роста. Рост должен быть больше 0 и не превышать 3 метра."
if weight <= 0 or weight > 200:
return "Ошибка ввода веса. Вес должен быть больше 0 и не превышать 200 кг."
return None # Успешная проверка