From e0fb94d2990b742f1fa3277939eec7a2ed41eb5c Mon Sep 17 00:00:00 2001 From: dr_domi Date: Sat, 2 May 2026 19:23:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/backend.py b/backend.py index 38940b7..0631dbb 100644 --- a/backend.py +++ b/backend.py @@ -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 # Успешная проверка \ No newline at end of file