#Please execute this cell
import sys;
sys.path.append('../../');
import jupman;
jupman.init('../../')
#NOTE: init() injects js and css stuff, which might not be necessary for exercises
# and sometimes even undesirable
# Please read https://jupman.readthedocs.io/en/latest/usage.html#Running-Jupyter
There won't be any internet access. You will only be able to access:
Bonus point: One bonus point can be earned by writing stylish code. You got style if you:
avoid convoluted code like i.e.
if x > 5:
return True
else:
return False
when you could write just
return x > 5
For example, if you are given to implement:
def f(x):
raise Exception("TODO implement me")
and you ship this code:
def my_f(x):
# a super fast, correct and stylish implementation
def f(x):
raise Exception("TODO implement me")
We will assess only the latter one f(x)
, and conclude it doesn't work at all :P !!!!!!!
Helper functions
Still, you are allowed to define any extra helper function you might need. If your f(x)
implementation calls some other function you defined like my_f
here, it is ok:
# Not called by f, will get ignored:
def my_g(x):
# bla
# Called by f, will be graded:
def my_f(y,z):
# bla
def f(x):
my_f(x,5)
To edit the files, you can use any editor of your choice:
To run the tests, use the Terminal which can be found in Accessories -> Terminal
If you need to print some debugging information, you are allowed to put extra print
statements in the function bodies.
For example, avoid stuff like this:
x = 0
print(1/x)
1) Download jupman-2000-12-31-exam.zip
and extract it on your desktop. Folder content should be like this:
jupman-2000-12-31-FIRSTNAME-LASTNAME-ID
|-jupman.py
|-other stuff ...
|-exams
|-2000-12-31
|- examA_exercise.py
|- examA_test.py
|- examB_exercise.py
|- examB_test.py
2) Rename jupman-2000-12-31-FIRSTNAME-LASTNAME-ID
folder: put your name, lastname an id number, like jupman-2000-12-31-john-doe-432432
From now on, you will be editing the files in that folder. At the end of the exam, that is what will be evaluated.
3) Edit the files following the instructions in this worksheet for each exercise. Every exercise should take max 25 mins. If it takes longer, leave it and try another exercise.
You are going to do.... something
from exercise1_solution import *
from exercise1_test import *
EnvWorkingTest
¶Now open the file exercise1.py
and check your environment is working fine, by trying to run the test EnvWorkingTest
: it should always pass, if it doesn't, tell your instructor.
Notice that exercise1
is followed by a dot and test class name: .EnvWorkingTest
python -m unittest exercise1.EnvWorkingTest
jupman_run(EnvWorkingTest)
do_something
¶Implement the method do_something
:
def do_something(self):
""" Does something """
raise Exception("TODO IMPLEMENT ME !!!")
Testing
Once done, running this will run only the tests in DoSomethingTest
class and hopefully they will pass.
Notice that exercise1
is followed by a dot and test class name .DoSomethingTest
:
python -m unittest exercise1.DoSomething
jupman_run(DoSomethingTest)
do_something_else
¶Implement the method do_something_else
:
def do_something_else(self):
""" Does something """
raise Exception("TODO IMPLEMENT ME !!!")
Testing: python -m unittest exercise1.DoSomethingElse