2: Parts of Python


We're going to take a tour of Python. You are expected to know generally what these things are, you're not yet expected to know how to use them. So no freaking out. We'll play around with some fun projects after a quick look around.

Learning Targets

  • I can make a hello world app in Python.

  • I can differentiate between compile-time, run-time, and logic errors.

  • I can describe the basic constructs of programming languages such as variables, conditionals, loops, and flow control.


  • You will be answering comprehension questions about the layers supporting software execution.

  • You will be creating and submitting your first Python app using trinket.io

Let's go to trinket.io and build some simple stuff, starting with print("Hello, world")

We'll go over each of these concepts in greater detail. For now, let's skim over all the big topics.

Data Types

The first thing we'll tinker with is declaring variables and storing information. Variables in Python are dynamically typed, meaning you can store one type of information in a variable and then switch it without any fuss. Other languages are more strict and don't allow such shenanigans.


We use math symbols for most common operations. But Python has some cool operators. Read!

Yeah, reading. Push yourself to skim tech guides so you know what's availabe.


Now we're switching from declarations and operations to control flow. Now we can direct the computer's train of thought (aka its thread).


This is how we repeat commands and iterate through a list or collection of items. Imagine you're using your hand to flip through posters at Walmart. Your hand selects each poster as it traverses the collection. That makes your hand the iterator as it is connecting with each object in the collection during the loop.

x in this loop is the iterator as it's the variable that traverses the collection


A function is a set of commands you can call. When activating this "magic spell" you can pass it parameters or ingredients.

the "return" keyword is a big one
Whoa, combining concepts!


This concept is pretty advanced. It's here as a reference point because exposure to these ideas is good (so long as you know that it's not something you need to master quite yet).

A class is how you can create your own objects. You can make an class serve as a single worker like a static library of mathematical operations or you can design your own object, like a Spaceship that can be spawned or instantiated into a game many times. It'll have its own instance variables like health and shield properties.