-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathOOPS.py
27 lines (23 loc) · 852 Bytes
/
OOPS.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
class Human:
# attributes
def __init__(self, name, height, weight):
self.name = name
self.height = height
self.weight = weight
# behaviours
def eating(self, food):
return ("{} is eating {}".format(self.name, food))
# creating objects
ram = Human("Ram", 6, 60)
praveen = Human("Praveen", 5.9, 56)
arun=Human("Arun",6.0,50)
# printing object information
print("Height of {} is {}".format(ram.name, ram.height))
print("Weight of {} is {}".format(ram.name, ram.weight))
print(ram.eating("Pizza"))
print("Weight of {} is {}".format(praveen.name, praveen.height))
print("Weight of {} is {}".format(praveen.name, praveen.weight))
print(praveen.eating("Banana"))
print("Weight of {} is {}".format(arun.name, arun.height))
print("Weight of {} is {}".format(arun.name, arun.weight))
print(arun.eating("Rice"))