-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaths
More file actions
33 lines (26 loc) · 756 Bytes
/
maths
File metadata and controls
33 lines (26 loc) · 756 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
"""
Python does offer magic methods like sum() and others, please try to write down your algorithms or coding
instructions clearly without using any shortcuts
"""
# Multiply 3 and any number
def mult(number):
print(number * 3)
# adds two numbers together
def add(a, b):
a+b = c
print(c)
"""
Using data structures like list, can you find the total or the values in that list.
Do not use a function like sum(someList), that would be cheating ;-)
"""
# Data structure
numbers = [1,2,3,6]
def sumOfListNumbers(someList):
theSum = 0
for i in someList:
theSum = theSum + i
print(theSum)
# Program checker (do not change the lines below)
assert sumOfList(numbers) == 12
assert mult(3) == 9
assert add(1,3) == 4