forked from flatironinstitute/sciware-testing-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise.py
67 lines (49 loc) · 1.09 KB
/
exercise.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
"""Main module template with example functions."""
def sum_numbers(number_list):
"""Sums a list of numbers using a for loop.
Parameters
----------
number_list : list
List of ints or floats
Returns
-------
int or float
Sum of list
Example
-------
>>> sum_numbers([1,2,3])
6
Add another doctest below
>>> 1
1
"""
sum_val = 0
for n in number_list:
sum_val += n
return sum_val
def add_vectors(vector_1, vector_2):
"""Adds the corresponding elements of two lists of numbers.
Parameters
----------
v1 : list
List of ints or floats
v2 : list
List of ints or floats
Returns
-------
list
Sum of lists
"""
add_vec = []
for a, b in zip(vector_1, vector_2):
add_vec.append(a * b)
return add_vec
def count_ones(input_list):
count = 0
for n in input_list:
if n == 1:
count += 1
return count
# Make a new function which counts the number of twos in a list
#def count_twos(input_list):