Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Case

Assignments week 1 Computational neuroscience

Rating
-
Sold
-
Pages
3
Grade
8-9
Uploaded on
21-06-2022
Written in
2021/2022

Score 95/100 points.

Institution
Course

Content preview

Before you turn this problem in, make sure everything runs as expected. First, restart the
kernel (in the menubar, select Kernel→Restart) and then run all cells (in the menubar,
select Cell→Run All).
Make sure you fill in any place that says YOUR CODE HERE or "YOUR ANSWER HERE", as
well as your name and collaborators below:
NAME = Kiki Boumans
COLLABORATORS =



Assignments week 1
Complete the assignments below, save the notebook and submit them on canvas.

Assignment 1.1
Many functions rely on loops to create complex behavior. For example, multiplication could
be implemented as a loop of additions. Write a function that multiplies two natural
numbers (positive integers) by using a loop of additions.
def multiplication(a,b):
"""
Multiplies two numbers by using a loop of additions.
"""
my_sum = 0
if b >= 0:
while a >= 1:
a = a - 1
my_sum = my_sum + b
else:
return 0
return my_sum



from nose.tools import assert_equal
a = 3
b = 6
assert_equal(multiplication(a,b), a * b)

a = 2
b = -3
assert_equal(multiplication(a,b), 0)

Assignment 1.2
Write a function that checks whether its input is a multiple of 3 and returns 1 if it is and 0 if
it is not. Hint: think back of remainders in integer division.

Written for

Institution
Study
Course

Document information

Uploaded on
June 21, 2022
Number of pages
3
Written in
2021/2022
Type
CASE
Professor(s)
M. senden
Grade
8-9

Subjects

$5.28
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF


Also available in package deal

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
kikiboumans Maastricht University
Follow You need to be logged in order to follow users or courses
Sold
154
Member since
5 year
Number of followers
88
Documents
25
Last sold
1 month ago

4.2

16 reviews

5
5
4
10
3
0
2
1
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions