-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice.py
More file actions
46 lines (36 loc) · 714 Bytes
/
practice.py
File metadata and controls
46 lines (36 loc) · 714 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def sum_elements(elems):
"""
list(int) -> int
sum all elements in list
"""
sum = 0
for elem in elems:
sum += elem
return sum
def multiply_elements(elems):
"""
list(int) -> int
multiply all elements in list
"""
sum = 1
for elem in elems:
sum *= elem
return sum
def largest_num(elems):
"""
list(int) -> int
return largest number in list
"""
maxNum = 0
for elem in elems:
maxNum = max(elem,maxNum)
return maxNum
def smallest_num(elems):
"""
list(int) -> int
return smallest number in list
"""
minNum = 0
for elem in elems:
minNum = min(elem,minNum)
return minNum