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?
Quick reference notes for students: variables, lists, dictionaries, conditionals, loops, functions and libraries.
Quick reference
Use this index to jump directly to the Python topic you need.
Jupyter Notebook 1
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
Jupyter Notebook 2
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"
inChecks 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"
Jupyter Notebook 3
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."
Jupyter Notebook 4
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 % nTakes the nth modulo of the number.
print(23 % 5)
>> 3
number // nPerforms 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
Jupyter Notebook 5
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
ABOUT US
PROGRAMS
COURSES
© All rights reserved TechSpark Academy Sàrl (LLC) 2019
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.
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.
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.