-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturn_semantics.py
More file actions
77 lines (63 loc) · 1.4 KB
/
Copy pathreturn_semantics.py
File metadata and controls
77 lines (63 loc) · 1.4 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
Learn about return semantics and function arguments in Python
"""
def egg(var):
"""
returns the variable back to the user
:param var: input object
:return: input object
"""
return var
# Required parameters must come first
# Optional parameters after required parameters
def sum_two(num1, num2=8):
"""
Sum two input integer objects
:param num1: object 1
:param num2: object 2 (optional), default is = 8
:return: sum of objects
"""
total = num1 + num2
print(num1," + ", num2, " = ", total)
return total
def banner(message, border='*'):
"""
Print message in banner form
:param message: String to print
:param border: border character for string
:return:
"""
print(border * len(message))
print(message)
print(border * len(message))
def add_spam(menu=None):
"""
Add spam to the menu list
:param menu:
:return: menu list
"""
if menu is None:
menu = []
menu.append('spam')
return menu
def main():
"""
Test function
:return:
"""
c = [6, 10, 20]
e = egg(c)
print(c is e)
n1 = 3
n2 = 9
sum_two(n1, n2)
sum_two(n1)
banner("Weber State")
banner("Weber State University", "$")
breakfast = ['eggs', 'bacon']
print("Before", breakfast)
add_spam(breakfast)
print("After", breakfast)
if __name__ == '__main__':
main()
exit(0)