/
main.py
51 lines (37 loc) · 1.01 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
"""
Small Python Projects for Beginners
BMI Calculator
Version: 1.1
Python 3.10+
Date created: July 16th, 2022
Date modified: December 18th, 2023
"""
def calculate_bmi(weight: float, height: float):
"""
Calculates the Body Mass Index (BMI) using the given weight and height.
Args:
weight (float): The weight of the person in kilograms.
height (float): The height of the person in meters.
Returns:
None
Raises:
None
"""
bmi: float = weight / (height * height)
if bmi < 18.5:
print("Underweight")
elif bmi >= 25:
print("Overweight")
else:
print("Normal weight")
def main():
"""
Entry point of this program.
Get weight and height entered by the user and invoke calculate_bmi().
"""
weight: float = float(input("Please enter your weight (kg): "))
height: float = float(input("Please enter your height (m): "))
calculate_bmi(weight, height)
if __name__ == "__main__":
main()