Jupyter example

Download exercises zip

Browse files online

Example of notebook for exercises in Jupyter files.

For python files based example and more, see Python example

What to do

  • unzip exercises in a folder, you should get something like this:

jupyter-example
     jupyter-example.ipynb
     jupyter-example-sol.ipynb
     jupman.py
     my_lib.py

WARNING: to correctly visualize the notebook, it MUST be in an unzipped folder !

  • open Jupyter Notebook from that folder. Two things should open, first a console and then browser. The browser should show a file list: navigate the list and open the notebook jupyter-example/jupyter-example.ipynb

  • Go on reading that notebook, and follow instuctions inside.

Shortcut keys:

  • to execute Python code inside a Jupyter cell, press Control + Enter

  • to execute Python code inside a Jupyter cell AND select next cell, press Shift + Enter

  • to execute Python code inside a Jupyter cell AND a create a new cell aftwerwards, press Alt + Enter

  • If the notebooks look stuck, try to select Kernel -> Restart

[2]:
# REMEMBER TO  IMPORT jupman !
# This cell needs to be executed only once, you can usually find it at the beginning of the worksheets

import jupman
[3]:
x = [1,2,3]
y = x
jupman.pytut()
[3]:
Python Tutor visualization
[4]:
y = [1,2,3]
w  = y[0]
jupman.pytut()
[4]:
Python Tutor visualization

Exercise 1

Implement inc function:

Show solution
[5]:

def inc(x): raise Exception('TODO IMPLEMENT ME !')

Exercise 2

Implement upper function

Show solution
[6]:
def upper(x):
    raise Exception('TODO IMPLEMENT ME !')

Exercise 3

Note everything after the ‘write here’ comment will be discarded. Note you can put how many spaces you want in the comment

Show solution
[7]:


w = 5 # write here

Exercise 4

Shows how to completely remove the content of a solution cell (including the solution comment)

EXERCISE: write a function that prints ‘hello’

Show solution
[8]:

Exercise 5

Shows the QUESTION / ANSWER feature. All content in ‘ANSWER:’ cell will be stripped

QUESTION: Describe why iPhone n + 1 is better than iPhone n

Show answer

Conclusion

bla bla

Relative image test, Markdown format:

cc-by-78342

Relative image test, HTML img tag:

cc-by-1243

Relative link test, Markdown format:

Back to index

Relative link test, HTML a tag:

Back to index