-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
48 lines (36 loc) · 907 Bytes
/
functions.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# Example file for working with functions
# LinkedIn Learning Python course by Joe Marini
#
# TODO: define a basic function
def func1():
print("I am a function")
# TODO: function that takes arguments
def func2(arg1,arg2):
print(arg1 , ' ' , arg2)
# TODO: function that returns a value
def cube(x):
return x*x*x
# TODO: function with default value for an argument
def power(num, x=1):
result = 1;
for i in range(x):
result = result * num
return result
# TODO: function with variable number of arguments
# Can have arg that comes before multi-argument list, but not after.
def multiadd(*args):
result = 0
for x in args:
result = result + x
return result
# func1()
# print(func1())
# print(func1)
# func2(10,20)
# print(func2(10,20))
# print(cube(3))
# print(power(2))
# print(power(2,3))
# print(power(x=3,num=2))
print(multiadd(4,5,10,10,4))