-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctions.py
More file actions
31 lines (22 loc) · 804 Bytes
/
Functions.py
File metadata and controls
31 lines (22 loc) · 804 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
# Functions
# Reduces the amount of code
# Can be called anywhere
# Functions must be given a name
# Can contain multiple parameters or none at all
# A parameter can have default values
def addWithArgs(num1, num2):
print(num1+num2)
addWithArgs(5, 3)
def addWithReturn(num1, num2):
return num1 + num2
result = addWithReturn(5, 3)
print(result)
def addWithDefaultArgs(num1, num2=3):
return num1 + num2
result = addWithDefaultArgs(5)
print(result)
def funcWithMultipleReturs(num1, num2):
"""This function returns sum and product of parameters""" # This line documents the function, describes its purpose...
return num1 + num2, num1 * num2
result = funcWithMultipleReturs(5, 3) # Doc string is visible in parameter section
print(result)