forked from ak4shp/learning-python-month-1-akash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12-practice_class.py
More file actions
28 lines (22 loc) · 911 Bytes
/
12-practice_class.py
File metadata and controls
28 lines (22 loc) · 911 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
27
28
class Person:
# Constructor ->
def __init__(self, name, age : int, skill, gender) -> None:
self.first_name = name
self.my_age = age
self.quality = skill
self.my_gender = gender.title()
# Methods ->
def about_me(self):
return f"I'm {self.first_name} {self.my_age} years old. My skill is {self.quality} and I am a {self.my_gender}."
def age(self):
return f"{self.first_name} is {self.my_age} years old."
def skill(self):
return f"{self.first_name} has {self.quality} as skill(s)."
def gender(self):
return f"{self.first_name} is a {self.my_gender}."
# Objects of class person
roney = Person("Roney", 21, "Bussiness Administration, F1 Racing", "male")
mira = Person("Mira", 22, "Fashion designing", "FEMALE")
roy = Person("Roy", 34, "Paramounting", "MaLe")
# Calling class methods for the object
print(roy.age())