Skip to content

Commit 5c3d402

Browse files
Add files via upload
1 parent 979e5b7 commit 5c3d402

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

Hierarchical.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Python program to demonstrate Hierarchical inheritance
2+
3+
# Base class
4+
class Parent:
5+
def func1(self):
6+
print("This function is in parent class.")
7+
8+
# Derived class1
9+
class Child1(Parent):
10+
def func2(self):
11+
print("This function is in child 1.")
12+
13+
# Derivied class2
14+
class Child2(Parent):
15+
def func3(self):
16+
print("This function is in child 2.")
17+
18+
19+
# Driver's code
20+
object1 = Child1()
21+
object2 = Child2()
22+
object1.func1()
23+
object1.func2()
24+
object2.func1()
25+
object2.func3()

example9_overloading.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# class Greeting:
2+
#
3+
# def sayHello(self, name = None, wish = None):
4+
# if name is not None and wish is not None:
5+
# print ('Hello' + name + wish)
6+
# elif name is not None and wish is None:
7+
# print ('Hello' + name)
8+
# else:
9+
# print ('Hello')
10+
# greet = Greeting()
11+
# # Call the method with zero, one and two parameters
12+
# greet.sayHello()
13+
# greet.sayHello('Ram')
14+
# greet.sayHello('Ram,', 'Good Morning!!!')
15+
16+
#area of rectange, circle square
17+
# class Area:
18+
# def area(self, l=None , b=None , r=None):
19+
# if l is not None and b is not None and r is None:
20+
# print("area of rectange:",l*b)
21+
# elif l is not None and b is None and r is None:
22+
# print("area of square:",l**2)
23+
# elif l is not None and b is not None and r is not None:
24+
# print("area of circle:",3.14*r**2)
25+
# print("area of square:", l ** 2)
26+
# print("area of rectangle:", l*b)
27+
# a1=Area()
28+
# a1.area(int(input()),int(input()))
29+
# a1.area(int(input()))
30+
# a1.area(int(input()),int(input(),int(input())))
31+
32+

0 commit comments

Comments
 (0)