-
Notifications
You must be signed in to change notification settings - Fork 0
/
INHERITANCE EXAMPLE 1.py
50 lines (46 loc) · 1.67 KB
/
INHERITANCE EXAMPLE 1.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class student:
def __init__(self, name, id, cgpa):
self.name = name
self.id = id
self.cgpa = cgpa
def do_class(self):
print("Class done", "Name:", self.name, "ID:", self.id, "CGPA:", self.cgpa)
class cse_student(student):
def do_lab(self):
print("Lab done for student", "Name:", self.name, "ID:", self.id, "CGPA:", self.cgpa)
class eee_department(student):
def do_lab(self):
print("Lab done for student", "Name:", self.name, "ID:", self.id, "CGPA:", self.cgpa)
##################### command ##########
# st1 = student()
# st1.info("Peter Parker", 22301229, 4.00)
# st1.do_class()
# st2 = cse_student()
# st2.info("Peter Parker", 22301229, 4.00)
# st2.do_lab()
#s1 = student("Peter Parker", 22301229, 3.5)
c1 = cse_student("Peter Parker", 22301229, 3.6)
c1.do_lab()
class student:
def __init__(self, name, id, cgpa):
self.name = name
self.id = id
self.cgpa = cgpa
def do_class(self):
print("Class done", "Name:", self.name, "ID:", self.id, "CGPA:", self.cgpa)
class cse_student(student):
def do_lab(self):
print("Lab done for student", "Name:", self.name, "ID:", self.id, "CGPA:", self.cgpa)
class eee_department(student):
def do_lab(self):
print("Lab done for student", "Name:", self.name, "ID:", self.id, "CGPA:", self.cgpa)
##################### command ##########
# st1 = student()
# st1.info("Peter Parker", 22301229, 4.00)
# st1.do_class()
# st2 = cse_student()
# st2.info("Peter Parker", 22301229, 4.00)
# st2.do_lab()
#s1 = student("Peter Parker", 22301229, 3.5)
c1 = cse_student("Peter Parker", 22301229, 3.6)
c1.do_lab()