forked from bytesenseidk/Mixed-Applications
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBMI.py
More file actions
26 lines (16 loc) · 623 Bytes
/
BMI.py
File metadata and controls
26 lines (16 loc) · 623 Bytes
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
class MyBMI(type):
def __call__(cls, *args, **kwargs):
height, weight = args
print(f"With a height of {height}m. and weight {weight}kg.")
print("Your Body Mass Index is: ")
return type.__call__(cls, *args, **kwargs)
class BMI(metaclass=MyBMI):
def __init__(self, height, weight):
self.height = height
self.weight = weight
def formula(self):
return round(self.weight / (self.height**2), 1)
def __str__(self):
return str(self.formula())
if __name__ == "__main__":
print(BMI(1.78, 90))