We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fd26349 commit d79c98aCopy full SHA for d79c98a
inheritance_in_python/inheritance.py
@@ -0,0 +1,25 @@
1
+class Parent:
2
+ def __init__(self, last_name, eye_color):
3
+ print("Parent Constructor Called")
4
+ self.last_name = last_name
5
+ self.eye_color = eye_color
6
+
7
+ def show_info(self):
8
+ print("Last Name - " + self.last_name)
9
+ print("Eye color - " + self.eye_color)
10
11
12
+class Child(Parent):
13
+ def __init__(self, last_name, eye_color, num_of_toys):
14
+ print("Child Constructor Called")
15
+ Parent.__init__(self, last_name, eye_color)
16
+ self.number_of_toys = num_of_toys
17
18
19
+billy_cyrus = Parent("Cyrus", "blue")
20
+# print(billy_cyrus.last_name)
21
+billy_cyrus.show_info()
22
23
+# miley_cyrus = Child("Cyrus", "Blue", 5)
24
+# print(miley_cyrus.last_name)
25
+# print(miley_cyrus.number_of_toys)
0 commit comments