-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathS09L59_script00.py
26 lines (15 loc) · 1005 Bytes
/
S09L59_script00.py
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
#Keyword Arguments and default parameters
def about(name,age,likes): # name,age and likes are parameters of the function
sentence = "Meet {} ! they are {} old and they like {}".format(name,age,likes)
return sentence
print(about("carlos",39,"ice-cream")) # carlos,39, ice-cream are arguments
print(about(name = "carlos", likes = "ice-cream", age = 39)) # We can do it like this using Keyword Arguments
# but always for the function about we will need to pass the arguments for the three parameters name,age,likes
#If we define the function about2 as:
def about2(name,age,likes = "sleep"): # name,age and likes are parameters of the function
sentence = "Meet {} ! they are {} old and they like {}".format(name,age,likes)
return sentence
# we have the default parameter likes with the argument "sleep", so if we don't use any it would take this value as default as for example:
print(about2("luis",33))
#but we can modify the default value
print(about2("Michael",44,"football"))