Skip to content
  • IN PERSON

    Our CAMPS

    Day Camps

    |  Geneva

    |  Lausanne

    |  Zug

    |  Zürich

    Residential Camps

    |  Oxford (UK)

    |  Cambridge (UK)

    Our WORKSHOPS

    Workshops

    Hack @ Google 

    Our CODING CLUBS

    After-School Clubs

  • ONLINE

    Our PROGRAMS

    1:1 Tutoring

    Mentoring 

    Group Classes

    Login

     

    | Parents 

    | Instructors

  • COURSES

    Browse All Courses

    Trending Courses:

    Animation & Game Design: Age 8-11

    Code in Python: Age 10-17

    Web Design: Age 10-17

    Future Ready: AI & Digital Innovation: Age 13-17

    Future Ready: AI & Cybersecurity: Age 13-17

  • ABOUT US

    Our World 

    Our Team

    Our Story

    Our Instructors

    Our Partners 

    Outreach

    | Initiatives 
    | Scholarship

  • DISCOVER

    Blog

    FAQs 

    Contact Us

    Parent Session

    Student Resources 

    Teach with Us

  • IN PERSON
    • Our CAMPS
      • Day Camps
        • Geneva
        • Lausanne
        • Zug
        • Zürich
      • Residential Camps
        • Oxford (UK)
        • Cambridge (UK)
    • Our WORKSHOPS
      • Hack @ Google
    • Our CODING CLUBS
  • ONLINE
    • 1-to-1 Tutoring
    • Group Classes
    • Personal Mentor
    • LOGIN
      • Parents
      • Instructors
  • COURSES
    • Browse ALL Courses
    • Trending Courses:
    • Animation & Game Design: Age 8-11
    • Code in Python: Age 10-17
    • Web Design: Age 10-17
    • Future Ready: AI & Digital Innovation: Age 13-17
    • Future Ready: AI & Cybersecurity: Age 13-17
  • ABOUT US
    • Our World
    • Our Team
    • Our Story
    • Our Partners
    • Our Instructors
    • Outreach
      • Initiatives
      • Scholarship
  • DISCOVER
    • Blog
    • FAQs
    • Contact Us
    • Parent Session
    • Student Resources
    • Teach with Us
  • IN PERSON
    • Our CAMPS
      • Day Camps
        • Geneva
        • Lausanne
        • Zug
        • Zürich
      • Residential Camps
        • Oxford (UK)
        • Cambridge (UK)
    • Our WORKSHOPS
      • Hack @ Google
    • Our CODING CLUBS
  • ONLINE
    • 1-to-1 Tutoring
    • Group Classes
    • Personal Mentor
    • LOGIN
      • Parents
      • Instructors
  • COURSES
    • Browse ALL Courses
    • Trending Courses:
    • Animation & Game Design: Age 8-11
    • Code in Python: Age 10-17
    • Web Design: Age 10-17
    • Future Ready: AI & Digital Innovation: Age 13-17
    • Future Ready: AI & Cybersecurity: Age 13-17
  • ABOUT US
    • Our World
    • Our Team
    • Our Story
    • Our Partners
    • Our Instructors
    • Outreach
      • Initiatives
      • Scholarship
  • DISCOVER
    • Blog
    • FAQs
    • Contact Us
    • Parent Session
    • Student Resources
    • Teach with Us

Jupyter Notebook Cheat Sheets

Quick reference notes for students: variables, lists, dictionaries, conditionals, loops, functions and libraries.

#

Quick reference

Cheat Sheet Index

Use this index to jump directly to the Python topic you need.

1VariablesJupyter Notebook 1 2Lists, including DictionariesJupyter Notebook 2 3ConditionalsJupyter Notebook 3 4LoopsJupyter Notebook 4 5Functions & LibrariesJupyter Notebook 5
1

Jupyter Notebook 1

Variables

print("...")

Prints an output defined by the user. It can also be used to print out variables.

print("Hello world")
>> Hello world

name = "Alvin"
print("Hello", name, "how are you?")
>> Hello Alvin how are you?

input("...")

Inputs can be used to save a variable typed in by the user.

name = str(input("What is your name?"))
>> What is your name? Kate

print("Hello", name)
>> Hello Kate

int(...)

Tells Python an input is an integer.

saved_num = int(input("Write your favourite number"))
>> Write your favourite number 42

float(...)

Tells Python an input is a float.

saved_num_2 = float(input("Write your favourite number"))
>> Write your favourite number 42.1

str(...)

Tells Python the input is a string.

name = str(input("What is your name?"))
>> What is your name? Franziska

len(...)

Returns the length of a string.

name = "Samuel"
print(len(name))
>> 6
2

Jupyter Notebook 2

Lists & Dictionaries

Dictionaries

Dictionaries are special lists. They are defined using curly brackets { ... }. You can access them using keys instead of indexes, which sometimes makes programming easier. Dictionaries are marked using { key : object } as follows:

favourite_things = {"food" : "sushi", "number" : 42, "language" : "French"}
print(favourite_things["language"])
>> "French"

list.append(...)

Adds an element to a list.

playlist = ["Believer", "Fireflies"]
playlist.append("Radioactive")
print(playlist)
>> "Believer", "Fireflies", "Radioactive"

list.pop(...)

Removes an element from a list.

playlist = ["Believer", "Fireflies", "Radioactive"]
playlist.pop(0)
>> "Fireflies", "Radioactive"

list[n]

Access the nth element of the list.

playlist = ["Believer", "Fireflies", "Radioactive"]
print(playlist[2])
>> "Radioactive"

print(playlist[0])
>> "Believer"

list[n] = ...

Replaces the nth element of the list.

playlist = ["Believer", "Fireflies", "Radioactive"]
playlist[2] = "My Life"
print(playlist)
>> "Believer", "Fireflies", "My Life"

in

Checks if an element is in a list.

playlist = ["Believer", "Fireflies", "Radioactive"]
print("Fireflies" in playlist)
>> True

string[...]

Strings are also lists.

name = "Emma"
print(name[3])
>> "a"
3

Jupyter Notebook 3

Conditionals

if (...):

Runs the indented code if the condition is fulfilled.

current_temperature = 240
target_temperature = 220

if current_temperature > target_temperature:
    print("The oven is too warm, let it cool down a bit.")

>> "The oven is too warm, let it cool down a bit."

elif (...):

Runs the indented code only if the condition before it is not fulfilled and its own condition is fulfilled.

current_temperature = 240
target_temperature = 260

if current_temperature > target_temperature:
    print("The oven is too warm, let it cool down a bit.")
elif current_temperature < target_temperature:
    print("The oven is too cold, let it warm up a bit.")

>> "The oven is too cold, let it warm up a bit."

else:

Runs the indented code only if all the conditions before it failed.

current_temperature = 240
target_temperature = 240

if current_temperature > target_temperature:
    print("The oven is too warm, let it cool down a bit.")
elif current_temperature < target_temperature:
    print("The oven is too cold, let it warm up a bit.")
else:
    print("The oven is ready.")

>> "The oven is ready."

len(...)

Calculates the length of a string or list.

playlist = ["One Day", "Next to Me", "Tri Poloski"]

if len(playlist) > 10:
    print("This is a long playlist")
else:
    print("This playlist is short.")

>> "This playlist is short."
4

Jupyter Notebook 4

Loops

There is a jump in difficulty between the last Jupyter notebook and this Jupyter Notebook. It is normal that the exercises take more time to solve. If you are stuck, ask your instructors. They are here to help.

range(n)

Creates a list going from 0 to n-1.

for i in range(3):
    print(i)

>> 0, 1, 2

range(start, stop, step)

Creates a list starting at “start”, stopping at “stop - 1” and going by “step”.

for k in range(1, 5, 1):
    print(k, "repeat")

>> 1 repeat, 2 repeat, 3 repeat, 4 repeat

for a in range(3): for b in range(2): print(a,":", b)

Nested loops.

for a in range(3):
    for b in range(2):
        print(a, ":", b)

>> 0 : 0
>> 0 : 1
>> 1 : 0
>> 1 : 1
>> 2 : 0
>> 2 : 1

number % n

Takes the nth modulo of the number.

print(23 % 5)
>> 3

number // n

Performs the whole division of the number through n.

print(23 // 5)
>> 4

print(4 * 5 + 23 % 5)
>> 23

list.split()

Splits a list at every space character.

text = "hello world"
for i in text.split():
    print(i)

>> hello
>> world
5

Jupyter Notebook 5

Functions & Libraries

from ... import ...

Imports a specific function from a library.

from math import sqrt
print(sqrt(4))
>> 2

import ... as ...

Imports a whole library as a string. Requires special syntax when calling functions.

import math as mt
print(mt.sqrt(4))
>> 2

from ... import *

Imports a whole library. Does not require specific syntax.

from math import *
print(sqrt(4))
>> 2

def ... (a, b):
    _____
    _____
    return(c)

Defines a function manually with arguments a and b, and returns c.

def addition(a, b):
    sum = a + b
    return(sum)

print( addition( 8, -6) )
>> 2

CONTACT

TechSpark Academy Sàrl (LLC)

Lausanne office

Chemin des Ramiers 8,

1009 Pully, Switzerland

TechSpark Academy Sàrl (LLC)

Zürich office

1 Wiesenstrasse

8700 Küsnacht, Switzerland

Marta Gehring

+ 41 79 697 13 00

marta@techsparkacademy.com

Kate Mckee

+41 76 736 90 09

kate@techsparkacademy.com

FOLLOW US

Instagram Facebook
GET OUR NEWS
TEACH WITH US

ABOUT US

About TechSpark Academy
Our Team
Our Partners
Outreach & Scholarships
Teach with Us
Partner with Us
Blog
Newsletter

PROGRAMS

Online 1-On-1 Tutoring
Online Group Classes
Online Mentoring
In-Person Day Camps
Residential Camps
After-School Clubs
Special Workshops
Bespoke Programs

COURSES

Browse All Courses
Code in Python
Animation & Game Design
Hacker Mode
Artificial Intelligence
Web Design
Mobile Apps with Swift
Digital Technology & the Environment
Robotics (in person only)

© All rights reserved TechSpark Academy Sàrl (LLC) 2019

Frequently Asked Questions

Privacy Policy         Terms & Conditions

Privacy Policy         Terms & Conditions

×

Web Design
with JavaScript

Build your own website while learning the basics of Java Script.

Students are introduced to the key principles of web design, user interface (UI) and user experience (UX), while learning the basics of Java Script- Students apply what they learn to their own custom website, adding text, images, audio, videos, hyperlinks, and more.

The course is ideal for students who have completed at least one coding course with TechSpark Academy, Animation and Game Design or Python, and are familiar with the basics of programming logic and computational thinking.

Some courses might not be available at every camp – check your preferred location and dates to view course offering.

View more course info

Code in Python
Beginner - Advanced

Learn Python, the language of Instagram, YouTube, and Google’s search engine!

Widely used by programmers, designers and game developers, Python has rapidly become one of the most popular programming languages.

This coding course is available in three levels so that kids and teens – with or without any previous experience – can develop their knowledge and skills at their pace (Juniors, Teens Beginner & Teens Advanced)

CODE IN PYTHON (Juniors): designed for kids aged 10+ this course serves as an introduction to the fun and rewarding world of coding.

CODE IN PYTHON (Teens Beginner): this course is designed for teens aged 12+ with no experience in programming. Students will become familiar with the fun and rewarding world of coding by learning the fundamentals of the Python language.

CODE IN PYTHON (Teens Advanced): this course is designed for teens aged 13+ with previous experience in coding and game development who want to further develop their knowledge.

View more course info

Animation & Game
Design

This course teaches students to program their own interactive stories, games, and animations, and share their creations with others in the online community, assembling lego-like blocks of code. Scratch is a visual based programming language which encourages kids to think creatively, reason systematically and work collaboratively.

Scratch was designed and is maintained by the Lifelong Kindergarten group at the MIT Media Lab in the spirit of playful and creative learning.

Discover the power of code with Scratch!

All classes are designed for small groups to foster a comfortable and fun setting, therefore there is only a maximum of 6 students for this course. 

View more course info