Adding Chapter 3 files
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#methodoverloading1.py
|
||||
class Car:
|
||||
def __init__(self, color, seats):
|
||||
self.i_color = color
|
||||
self.i_seat = seats
|
||||
|
||||
def print_me(self, i='basic'):
|
||||
if(i =='basic'):
|
||||
print(f"This car is of color {self.i_color}")
|
||||
else:
|
||||
print(f"This car is of color {self.i_color} with seats {self.i_seat}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
car = Car("blue", 5 )
|
||||
car.print_me()
|
||||
car.print_me('blah')
|
||||
car.print_me('detail')
|
||||
Reference in New Issue
Block a user