-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.py
More file actions
63 lines (47 loc) · 822 Bytes
/
function.py
File metadata and controls
63 lines (47 loc) · 822 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# def half(val):
# z = val/2
# return(z)
# x = 4
# y = 3
# a = half(x)
# b = half(y)
# print(a, b)
# def mean(a, b):
# c = (a + b) / 2
# return(c)
# x = mean(4, 6)
# print(x)
## working out max of two (and 3) variables!!!
# def max(a, b):
# if a < b:
# return b
# else:
# return a
# def maxx(a, b, c):
# if c < max(a, b):
# return(max(a, b))
# else:
# return c
# x = 4
# y = 18
# z = 16
# z1 = max(x, y)
# z2 = max(y, x)
# z3 = maxx(x, y, z)
# print(z3)
# Sum of list
def my_sum(lst):
e = sum(lst)
return(e)
my_list = [1,2,3,5]
s = my_sum(my_list)
print(s)
## Their solution:
# def my_sum(lst):
# acc = 0
# for number in lst:
# acc += number
# return acc
# my_list = [1,2,3,4]
# s = my_sum(my_list)
# print(s)