1def my_function(name, age = 20):
2 print(name + " is " + str(age) + " years old"
3
4my_function("Mitro") # Mitro is 20 years old
5my_function("Mitro", 26) #Mitro is 26 years old
1def my_function(num1,num2=0): #if num2 is not given, it will default it to zero
2 return num1 + num2
3
4print(my_function(1,2)) #prints out 3
5print(my_function(4)) #prints out 4 since num2 got defaulted to 0
1def screen_size(screen_size=80):
2 return screen_aize
3
4screen_size(120) # the screen size is 120
5screen_size() # the screen size is 80 as default
1def greet(name, msg="Good morning!"):
2 """
3 This function greets to
4 the person with the
5 provided message.
6
7 If the message is not provided,
8 it defaults to "Good
9 morning!"
10 """
11
12 print("Hello", name + ', ' + msg)
13
14
15greet("Kate")
16greet("Bruce", "How do you do?")