-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16_class_object_example.py
More file actions
59 lines (40 loc) · 1.46 KB
/
Copy path16_class_object_example.py
File metadata and controls
59 lines (40 loc) · 1.46 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# a class is the complete TEMPLATE of what we want to make
# every class has 2 kind of things:
# - a set of attributes
# - a set of actions
# Human being
# attribs: EyeColor, HairColor, SkinColor, Language, Height, Weight, Strength
# actions: Walk, Run, Eat, Sit, Jump, Stand, See, Hear, Touch
# Allu Arjun
# attribs: Black, Black, Fair, Telugu, 5.10, 65, High
#
class HumanBeing:
def __init__(self, Name, Place, EyeColor, HairColor, SkinColor, Language, Height, Weight, Strength):
self.Name = Name
self.Place = Place
self.EyeColor = EyeColor
self.HairColor = HairColor
self.SkinColor = SkinColor
self.Language = Language
self.Height = Height
self.Weight = Weight
self.Strength = Strength
def Walk(self):
print(self.Name, "is walking")
def Run(self):
print(self.Name, "is Running")
def Eat(self):
print(self.Name, "is Eating")
def Sit(self):
print(self.Name, "is Sitting")
h1 = HumanBeing("Allu Arjun", "Hyderabad", "Black", "Black", "Fair", "Telugu", 5.10, 65, "High")
h2 = HumanBeing("Shah Rukh Khan", "Mumbai", "Brown", "Black", "Fair", "Urdu", 5.8, 65, "Medium")
print(h1.Name)
print(h2.Name)
print(h1.Language)
print(h2.Language)
h2.Walk()
h1.Sit()
h3 = HumanBeing("Rajinikanth", "Chennai", "Black", "White", "Dark", ["Tamil", "Telugu"], 5.4, 75, "Less")
h3.Run()
print(h3.Language)