-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOP_Python.py
More file actions
37 lines (26 loc) · 1.09 KB
/
OOP_Python.py
File metadata and controls
37 lines (26 loc) · 1.09 KB
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
class BMI:
name=input("What is your name : ")
weight=float(input("How much is your weight: "))
height=float(input("How much is your height: "))
def bmi_calculator(self):
bmi = BMI.weight / (BMI.height ** 2)
print('Body mass index: '+str(bmi))
if bmi<25:
return BMI.name+' does not have excess weight !'
else:
return BMI.name+' has excess weight !'
bmi1=BMI()
print(bmi1.bmi_calculator())
-------------------------------------------------------------
class Person:
name=input("Input your name: ")
surname=input("Input your surname: ")
place_of_birth=input("Input your place of birthday: ")
year_of_birth=input("Input your year of birthday: ")
def print_info_person(self):
return f"name: {Person.name} , surname: {Person.surname} , place_of_birth: {Person.place_of_birth} , year_of_birth: {Person.year_of_birth} "
def get_age(self,current_year):
return f"{Person.name} {current_year-int(Person.year_of_birth)} years old !"
p1=Person()
print(p1.print_info_person())
print(p1.get_age(2021))