-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptionalparams2.py
More file actions
34 lines (25 loc) · 791 Bytes
/
Copy pathoptionalparams2.py
File metadata and controls
34 lines (25 loc) · 791 Bytes
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
'''def func(x):
return x **2
call = func(5)
print(call)
def func(x=1):
return x **2
call = func()
print(call)
def func(word, freq=1, add=5):
print(word*(freq+add))
call = func("da ", 3)'''
class car(object):
def __init__(self, make, model, year, condition="New", kms=0):
self.make = make
self.model = model
self.year = year
self.condition = condition
self.kms = kms
def display(self, showAll=True):
if showAll:
print("This car is a %s %s from %s, It is %s and has %s kms." %(self.make, self.model, self.year, self.condition, self.kms))
else:
print("This car is a %s %s from %s." %(self.make, self.model, self.year))
whip = car("Ford", "Fusion", 2012)
whip.display(False)