forked from mkalansari7/python-cw-7
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (26 loc) · 639 Bytes
/
main.py
File metadata and controls
35 lines (26 loc) · 639 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
29
30
31
32
33
34
#1
class Person1:
name = 'Ali'
age = 18
first_person = Person1
print(first_person.name,first_person.age)
#2
class Person2:
name = 'Ali'
age = 18
def is_adult(self):
if Person2.age >= 18:
print('You have too much responsibilities')
else:
print('Lucky you')
first_person = Person2
first_person.is_adult(first_person.age)
#3
class Person3:
def __init__(self,age,name):
self.age = age
self.name = name
def __str__(self):
return f"""My name is {self.name} and u am {self.age} year old """
first_person = Person3('Ali', 18)
print(first_person)