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 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
    • 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
    • Outreach
      • Initiatives
      • Scholarship
  • DISCOVER
    • Blog
    • FAQs
    • Contact Us
    • Parent Session
    • Student Resources
    • Teach with Us

Python Basics Cheat Sheet

Tips

Practice coding regularly.

Don’t be afraid to ask for help;)

Have fun and be creative!

1. Basic Python Syntax

To print text or messages on the screen, use the print() function.

• Print a message:

print (“Hello, World”)

• Comments:

# This is a single line comment

2. Variables and Data Types

Variables are used to store information.

• Variables:

age = 13
name = Alice

• Data Types
Common data types include:

  • Strings:  “Hello”
  • Integers:  123
  • Floats:  3.14
  • Booleans: True or False
number = 1
pi = 3.14
is_happy = True
greeting = “Hi”

3. Basic Operations

• Addition: +
• Subtraction: –
• Multiplication: *
• Division: /

• Arithmetic Operations:

addition = 5 + 3 #8
subtraction = 5 – 3 #2
multiplication = 5 * 3 #15
division = 5 / 3 #1.666…

• String Concatenation:

full_name = “Alice” + ” “ + “Smith”

4. Lists

Lists store multiple items in a single variable.

• Creating a list:

fruits = [ “apple”, “banana”, “cherry” ]

• Accesing list elements:

first_fruit = fruits[0] # “apple”

• Adding elements to a list:

fruits.append(“orange”)

5. Conditional Statements

Conditional statements are used to make decisions in your code.

• If, Elif, Else

if age < 13:
print(“You are a child.”)

elif age < 20:
print(“You are a teenager.”)

else:
print(“You are an adult.”)

6. Loops

Loops repeat a piece of code multiple times

• For Loop:

for fruit in fruits:
print(fruit)

• While Loop:

count = 0
while count < 5:
print(count)
count += 1

7. Functions

Functions are blocks of code that do a specific task.

• Defining a function:

def greet(name):
return “Hello” + name

print(greet(“Alice”)) # “Hello Alice”

8. Importing Libraries (also know as modules)

You can use external libraries to add more functionality to your code.

• Using a module:

import math print(math.sqrt(16)) # 4.0

9. Basic Input/Output

You can get input from the user with the input() function.

• Getting user input:

user_name = input (“What is your name?”)
print(“Nice to meet you,” + user_name)

10. Simple Error Handling

Use try and except to handle errors.

• Try/Except:

try:
result = 10/0
except ZeroDivisionError:
print(“You can’t divide by zero!””)

11. Dictionaries

Dictionaries store data in key-value pairs.

• Creating a dictionary:

student = {

“name”: “Alice”,

“age”: 13,

“grade”: “8th”,

}

# Accessing values

print(student[“name”]) # “Alice”

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

[email protected]

Kate Mckee

+41 76 736 90 09

[email protected]

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