Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions Method Overloading and Method Overriding.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@


(---Method Overloading---)
#
# class Student:
#
# def __init__(self,m1,m2):
# self.m1 = m1
# self.m2 = m2
#
# def sum(self,a=None,b=None,c=None):
#
# s = 0
#
# if a!=None and b!=None and c!=None:
# s = a+b+c
# elif a!=None and b!=None:
# s = a+b
# else:
# s = a
#
# return s
#
#
# s1 = Student(58,69)
#
# print(s1.sum(5))

class Student:

def __init__(self,m1,m2):
self.m1 = m1
self.m2 = m2

def sum(self,a=None,b=None,c=None):

s = 0

if a!=None and b!=None and c!=None:
s = a+b+c
elif a!=None and b!=None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there will be indentation error with this line

s = a+b
else:
s = a

return s


s1 = Student(58,69)

print(s1.sum(5))


(---Method Overriding---)
Expand Down