Добавил кода
This commit is contained in:
+18
-7
@@ -1,8 +1,19 @@
|
|||||||
def calculate(height, wight):
|
def calculate(height, weight):
|
||||||
result = wight / height ^ 2
|
result = weight / (height ** 2)
|
||||||
return result
|
return round(result, 2)
|
||||||
|
|
||||||
def user_input_check(height, wight):
|
def user_input_check(height, weight):
|
||||||
if height.isdigit() and wight.isdigit():
|
# Проверка, что введённые значения — числа
|
||||||
if height != 0 and wight != 0:
|
if not (height.replace('.', '', 1).isdigit() and weight.replace('.', '', 1).isdigit()):
|
||||||
return True
|
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 # Успешная проверка
|
||||||
Reference in New Issue
Block a user