South Plantation High School · Procedural Programming with Python
Welcome to Python
What it is · Where it came from · How it works · Lesson review
!
Review the lesson slides, then complete the assignment at the bottom of this page. Your assignment work is saved in this browser on this computer. When you check a task, your name, period, and which tasks are complete are shared with your teacher (your code is not). When you finish, print it or save it as a PDF to turn in.
1 / 16→ next · ← back · n notes · s script · f full
Lesson Review
Welcome to Python
print("Hello, World!")
What it is, where it came from, and how it works.
By the end of this lesson you will be able to:
Explain what a programming language is and what kind of language Python is.
Tell the story of who created Python, when, where, and how it got its name.
Describe how Python turns your code into results: source code, bytecode, and the interpreter.
Explain why Python stops at some errors right away and at others only when it reaches that line.
Use Python two ways: the interactive prompt (>>>) and a script (.py file).
How to use this page: Use Next and Back (or the arrow keys). Click the years on the timeline, try the >>> prompt, and use Step to watch Python run a program one line at a time.
Words you will hear today
Word
What it means
program
A list of instructions that a computer follows, in order, to do a job.
source code
The text of a program that a person writes, like print("Hello").
programming language
A set of words and grammar rules for writing source code. Python is one; Java and C are others.
syntax
The grammar rules of a language: where the parentheses, quotes, colons, and spaces go.
interpreter
The program that reads your Python code and carries it out.
bug
A mistake in a program that makes it stop or give the wrong result.
Python is a programming language: a way to give a computer instructions.
This lesson is the story and the "how it works" behind everything we write.
Source code is what you write; the interpreter carries it out.
Welcome to Python! Before we write programs, let's meet the language. Where did it come from? Why is it named after a comedy show? And what actually happens inside the computer when you click Run? By the end of today you will be able to answer all three.
The Big Idea
What is a programming language?
A computer's processor only understands machine code: very simple instructions stored as numbers (ones and zeros). Writing a whole app that way would take forever.
A programming language is a set of words and rules that people can read and write, which a program then translates into instructions the computer can run.
Low-level languages are close to the machine. They are fast but hard for people to read.
High-level languages, like Python, are close to human language. They are easier to read and write.
Analogy: You speak English, and a friend from another country speaks only Japanese. An interpreter sits between you and translates. Python's interpreter does that job between you and the computer.
The same idea at three levels
Here is how "store the number 97" might look at each level. Notice how each step up is easier for a person to read:
Level
Example
Who can read it easily?
Machine code
10110000 01100001
The processor
Assembly language
MOV AL, 61h
Experts who know that processor
Python (high-level)
x = 97
Almost anyone, after a little practice
Why not just program in English?
English is full of words that mean more than one thing. "Make it bigger" could mean the text, the window, or the number. A computer cannot guess what you meant, so a programming language has exact rules: every line can mean only one thing. That is why spelling, parentheses, and quotes matter so much in code.
Computers run machine code. People write in programming languages.
Python is a high-level language.
Programming languages are exact; every line has one meaning.
Computers are amazingly fast, but they only understand very simple instructions written as numbers. Programming languages let us write in something much closer to English, and then a translator program turns it into those numbers. Python is a high-level language, which means it is designed to be easy for people to read.
What Is Python?
What kind of language is Python?
The official Python documentation describes it as an interpreted, interactive, object-oriented programming language. It is also called a high-level, general-purpose language. Here is what those words mean:
High-level
Written in words close to English, not ones and zeros.
General-purpose
Used for many kinds of programs, not just one job.
Interpreted
You can run your code directly. You do not first build a separate program file to run.
Interactive
You can type one line at the >>> prompt and see the result right away.
Supports several styles
Object-oriented, and also procedural (step-by-step instructions, which is what we do in this class) and functional.
Free and everywhere
Free and open source. Anyone can download Python and read its source code. You can even use it to build products you sell.
Portable. Python runs on Windows, macOS, and Linux, so the same program can run on different computers.
The standard version that you download from python.org is called CPython. There are other versions too, but CPython is the main one.
Readable on purpose. Python uses indentation (spaces) to show which lines belong together, instead of lots of symbols. You have already seen this with if statements and loops.
What these words look like in practice
Interpreted: you click Run and the program starts right away. There is no separate "build" step that makes an .exe file first.
Interactive: at the >>> prompt, typing 5 * 4 and pressing Enter shows 20 immediately. It is like a very powerful calculator.
Object-oriented: in Python, every value (a number, a word, a list) is an object that comes with its own tools. For example, "hello".upper() gives "HELLO". You will use these tools all year.
Open source: the code that makes Python work is public. Anyone can read it, suggest fixes, or learn from it.
Indentation is not just style in Python. In many languages, spaces are only for looks. In Python, the spaces at the start of a line tell Python which lines belong to an if or a loop. Wrong indentation changes what the program does, or stops it with an IndentationError.
Free, open source, and runs on Windows, macOS, and Linux.
In Python, indentation is part of the grammar.
These are the words you will see whenever someone describes Python. High-level means easy to read. General-purpose means it is used for all kinds of jobs. Interpreted and interactive mean you can run code right away, even one line at a time. And it is free: you can install it at home tonight.
What Is Python?
"Hello, World!" in three languages
Programmers traditionally start a new language with a program that prints Hello, World! Compare how much you need to write.
Python
print("Hello, World!")
One line.
Java
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
A class, a main method, and semicolons.
C
#include <stdio.h>
int main(void) {
printf("Hello, World!\n");
return 0;
}
An include line, a main function, braces, and semicolons.
Every language has strengths. Java and C are powerful and widely used. Python's strength is that beginners can focus on ideas (decisions, loops, data) instead of extra punctuation, which is one reason it is so popular in schools.
Reading the Python line piece by piece
print is a function: a named tool that does a job. Its job is to show something on the screen.
The parentheses( ) hold what you are giving the function to work with.
The quotes" " mark the text as a string: words to show exactly as written.
Leave out the quotes and Python thinks Hello is the name of a variable. print(Hello) stops with NameError: name 'Hello' is not defined, because nothing named Hello was ever created.
Why "Hello, World!"? It is the smallest program that proves everything is set up correctly: the language is installed, the editor works, and you can see output. Programmers have used it as a first test since the 1970s.
Python needs the least extra code to do simple tasks.
Other languages are not "worse"; they are designed for different goals.
print is a function; quotes make a string.
All three programs do exactly the same thing. Python does it in one line. That does not make Java or C bad languages; they are used to build huge systems. But for learning to think like a programmer, Python lets you skip the extra punctuation and focus on the logic.
History
Where Python came from
Who:Guido van Rossum, a programmer from the Netherlands.
Where: a research center in the Netherlands called CWI.
When: he started writing Python during the 1989 Christmas holidays, as a hobby project.
Why: his team needed a better way to do system administration tasks than writing programs in C or shell scripts.
Ideas from: Python grew out of an earlier teaching language called ABC, which Guido had helped work on.
First release: in February 1991, after just over a year of work, he shared it publicly on USENET (an early internet discussion system). That version was numbered 0.9.0.
A holiday project that changed the world. Python started as one person's side project over winter break. Today millions of people use it, and thousands of volunteers help improve it.
Fun fact: For many years Guido had the playful title "Benevolent Dictator For Life" (BDFL), meaning he made the final decision on changes to Python. He stepped down from that role in July 2018.
Ideas Python borrowed from ABC
ABC was designed to be easy for beginners. Python kept some of its best ideas, including using indentation to group lines together and having simple, readable keywords. Guido also fixed things he did not like about ABC, such as how hard it was to add new features to it.
The goal: programming for everybody
In 1999 Guido wrote a proposal called "Computer Programming for Everybody." It described goals for Python: an easy and intuitive language that is still powerful, open source so anyone can help, code that reads like plain English, and good for everyday tasks. Those goals are a big reason Python is used in classrooms like this one.
Guido van Rossum, CWI in the Netherlands, started December 1989.
First public release: February 1991, version 0.9.0.
Python borrowed indentation and readability from ABC.
Python began as a hobby. Over the 1989 Christmas break, Guido van Rossum, a programmer at a research center in the Netherlands, decided to build the language he wished he had at work. He shared it with the world in February 1991. Not bad for a holiday project.
History
Why is it called "Python"?
It is not named after the snake!
While Guido was building the language, he was reading the scripts from "Monty Python's Flying Circus," a British comedy TV series from the 1970s made by the BBC.
He wanted a name that was short, unique, and slightly mysterious, so he named his language Python.
The jokes are encouraged. The official Python tutorial says the language "has nothing to do with reptiles," and that making references to Monty Python skits in the documentation is encouraged.
But the logo has snakes! Even though the name comes from a comedy show, Python's official logo is made of two snakes.
Quick check
Python was named after...
You will see the jokes in examples
Because of the Monty Python connection, Python examples often use the words spam and eggs as sample variable names, the same way math books use x and y. Those words come from a famous Monty Python sketch about a restaurant that puts spam in everything. If you see spam = 5 in an online example, now you know why.
Named after Monty Python's Flying Circus, a 1970s BBC comedy.
Guido wanted a short, unique, slightly mysterious name.
spam and eggs in examples are Monty Python references.
Here is the trivia question that wins games: Python is named after a comedy show, not a snake. Guido was a fan of Monty Python's Flying Circus and wanted a short name nobody else was using. The snakes only showed up later in the logo.
History
Python through the years
Click a year to read what happened.
How to read a version number
A version like 3.14.0 has three parts:
3 is the major version. It changes only when the language changes in big ways that can break old code (like 2 to 3).
14 is the minor version. A new one comes out about once a year with new features. Code from 3.13 almost always still works in 3.14.
0 is the micro (bug fix) version. These fix problems without adding new features.
Check your own version: type python --version in a terminal (on some Macs, python3 --version).
A new Python 3 version comes out about once a year.
Version numbers: major.minor.micro.
Click through the timeline with me. The big moments are 1991, when Python was first shared, 2008, when Python 3 arrived, and 2020, when Python 2 was officially retired. Today a new version of Python 3 comes out about every October.
History
Python 2 vs. Python 3
Python 3.0 came out on December 3, 2008. It cleaned up parts of the language, but that meant some Python 2 code no longer worked in Python 3.
The two versions were used side by side for years. Python 2 was officially retired on January 1, 2020, and it no longer gets fixes, even for security problems.
In this class we use Python 3. If you search online and find old examples, check the print line. That is the easiest way to spot Python 2 code.
Python 2 style (no parentheses)
print "Hello"
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
Python 3 (print is a function)
print("Hello")
Hello
That error is what Python 3 shows if you run the Python 2 style line. Python even tells you how to fix it.
Other changes you might notice in old code
Python 2
Python 3
Printing
print "Hi"
print("Hi")
7 / 2
3 (dropped the decimal)
3.5
Reading typed input
raw_input()
input()
The division change is a good example of why Python 3 was worth the trouble. In Python 2, 7 / 2 silently gave 3, which surprised many beginners. Python 3 gives the answer you expect from math class.
Copying code from the internet? If it uses print without parentheses or raw_input, it is Python 2 code and will not run as-is in this class.
Python 3: December 3, 2008. Python 2 retired: January 1, 2020.
Spot old code: print without parentheses.
Python 2 clues: print without parentheses, raw_input.
When Python 3 came out, it fixed some old design decisions, and that broke some older code. The most famous change is print: in Python 2 it was a statement with no parentheses, and in Python 3 it is a function with parentheses. If you ever copy code from the internet and get this error, you found Python 2 code.
Python Today
Who runs Python today?
The Python Software Foundation (PSF) is a non-profit organization, formed in 2001. It holds the rights to Python and works to support and promote it.
The Steering Council is a group of 5 people, elected by Python's core team, who make the final decisions about the language. It replaced the "BDFL" role after Guido stepped down in 2018.
The core team and community are volunteers and paid developers around the world who write, test, and review changes.
Open source in action: changes to Python are proposed in public documents called PEPs (Python Enhancement Proposals). Anyone can read them on peps.python.org.
Current version
As of October 2026, the newest released version is Python 3.14 (first released October 7, 2025). Python 3.15 is scheduled for release on October 9, 2026.
Version numbers change every year, so always check python.org for the latest.
Popularity
Python was ranked #1 on the TIOBE programming language index for September 2026. TIOBE is one well-known ranking of how popular languages are.
How a change gets into Python
Someone writes a PEP explaining the idea, why it is needed, and how it would work.
The community discusses it in public, and people point out problems or improvements.
The Steering Council accepts or rejects it.
If accepted, developers write and test the code, and it appears in a future version.
A PEP you will hear about: PEP 8 is Python's official style guide. It explains things like using 4 spaces for indentation and writing variable names in lowercase_with_underscores. Following it makes your code look like everyone else's, which makes it easier to read.
PSF: non-profit, formed 2001. Steering Council: 5 elected members.
Current: Python 3.14. Python 3.15 scheduled October 9, 2026.
PEP 8 is the Python style guide.
No single company owns Python. A non-profit foundation looks after it, and a five-person steering council, elected by the core team, makes the big decisions. Anyone can read the proposals for new features. That openness is a big reason so many people trust and use Python.
Python Today
What is Python used for?
Python is a general-purpose language, so it shows up almost everywhere. Here are areas python.org lists, with tools you may hear about:
Websites and web apps
Web frameworks like Django and Flask help build the server side of websites.
Science and data
Libraries like SciPy and Pandas help scientists and analysts work with numbers and data.
Education
Python is widely used to teach programming, because it is easy to read.
Desktop apps
Toolkits like Tk (included with most Python installs) and Qt build windows and buttons.
Helping programmers
Developers use Python to automate building, testing, and tracking bugs in software.
Business software
Python powers business systems like online stores and company management tools.
The skills transfer. Variables, decisions, loops, and functions work the same way no matter what you build. What you learn in this class is the foundation for all of these areas.
A few more places Python shows up
Artificial intelligence: popular machine-learning libraries such as PyTorch and TensorFlow are used mainly from Python.
Automation: short Python scripts rename hundreds of files, fill in spreadsheets, or download data while you do something else.
Hardware projects: the Raspberry Pi, a small low-cost computer made for learning, uses Python for many of its projects, like controlling lights and sensors.
Library vs. framework: a library is a collection of ready-made tools you can call from your program (like Pandas). A framework is a bigger structure that your code plugs into (like Django for websites). Both save you from writing everything from scratch.
Web, science and data, education, desktop apps, software tools, business.
The basics you learn here are used in all of them.
A library is tools you call; a framework is a structure you build inside.
Look at how different these areas are: websites, science, desktop apps, business software. They all use the same building blocks we are learning: variables, if statements, and loops. Learning Python well opens all of these doors.
How Python Works
What happens when you click Run?
Source code is the text you write. Python files end in .py.
Bytecode is a simpler, in-between form of your program that is quick for Python to run. You never have to write or read it.
The Python virtual machine is the part that actually carries out the bytecode instructions.
Interpreted vs. compiled: languages like C build a separate program file (an executable) that you run later. Python skips that: you run the .py file directly. That makes testing quicker, though Python programs usually run more slowly than compiled ones.
Bonus: when you import a module, Python may save its bytecode in a folder named __pycache__ so it loads faster next time. That is why you sometimes see .pyc files appear.
Follow one line through the steps
Say your file hello.py contains print(2 + 3).
You write the source code and click Run.
Python checks and compiles the whole file. It confirms the grammar is correct (the parentheses match, nothing is misspelled in a way that breaks the rules) and turns it into bytecode.
The virtual machine runs the bytecode: it adds 2 and 3 to get 5, then calls print with 5.
Output:5 appears on the screen.
Analogy: the source code is a recipe written for people. Bytecode is the same recipe rewritten as short, numbered steps. The virtual machine is the cook who follows those steps one at a time.
Source code, compile to bytecode, virtual machine runs it, output.
Interpreted: run the .py file directly.
Steps: write, check and compile, run, output.
When you click Run, two things happen. First, Python reads your whole file and turns it into bytecode, a simpler form it can run quickly. If anything breaks the grammar rules, it stops right there. Second, the virtual machine runs that bytecode from the top to the bottom. The next slide shows why that two-step process matters.
How Python Works
Two kinds of stops
Because Python checks the whole file before it runs anything, errors happen at two different times:
Error type
When it happens
Lines before it...
SyntaxError (grammar mistake, like a missing parenthesis)
During step 2, before anything runs
do not run
Runtime error (like NameError, when Python reaches a bad line)
During step 3, when Python gets to that line
already ran
Pick a version of the program and run it. Compare which lines print.
Why this matters: if your program prints nothing at all and shows a SyntaxError, Python never started running. Fix the grammar first. If some lines printed before the error, the problem is at the line the error message names.
Common runtime errors you will meet
Error
Example line
What went wrong
NameError
Print("Hi")
Python has no name Print. Names are case-sensitive; it should be print.
TypeError
"5" + 3
You cannot add text and a number together.
ZeroDivisionError
10 / 0
Dividing by zero has no answer.
Grammar problems are SyntaxErrors. A missing parenthesis, a missing quote, or a missing colon after if are all caught before anything runs. Wrong indentation shows up as an IndentationError, which is a special kind of SyntaxError.
Reading an error message: look at the last line first. It names the error type and gives a short explanation. The line above it shows the code that caused it, and the "line" number tells you where to look.
SyntaxError: found while compiling, nothing runs.
Runtime errors: found while running, earlier lines already ran.
Read the last line of an error first.
Names are case-sensitive: Print is not print.
This is one of the most useful things to understand about Python. With a NameError on line 3, lines 1 and 2 still print, because Python ran them before reaching the problem. With a SyntaxError on line 3, nothing prints at all, because Python checked the whole file first and refused to start.
How Python Works
Two ways to run Python
1. Interactive mode: the >>> prompt
Type one line, press Enter, and see the result right away. Python even shows the value of an expression without print(). It is great for quick tests, but nothing is saved.
2. Script mode: a .py file
Write a whole program in a file, save it, and run it. This is how real programs are made, and it is what our assignments use.
IDLE (Integrated Development and Learning Environment) usually comes with Python. It has both: a >>> shell window and an editor for .py files.
In script mode, a line like 2 + 3 by itself shows nothing. You need print(2 + 3). Only the interactive prompt shows values automatically.
Try the prompt. Type each of these, pressing Enter after each one:
2 + 3
"Hello"
name = "Ava" then name
print(name)
7 / 2
print "Hi" (Python 2 style)
Side by side
Interactive (>>>)
Script (.py file)
Runs
one line at a time, as you type
the whole file, top to bottom
Shows values without print?
Yes
No
Saved?
No, it is gone when you close it
Yes, you can run it again any time
Best for
quick experiments and checking an idea
real programs and assignments
Tips for the prompt: you never type the >>> yourself; Python shows it to say "I'm ready." When a line needs more (like after an if line), the prompt changes to ... to say "keep going." Type exit() to leave.
Interactive mode: quick tests, shows values, not saved.
Script mode: full programs saved in .py files.
Do not type the >>>; Python shows it when ready.
The prompt with three arrows is like a calculator that speaks Python. Try typing 2 plus 3: no print needed. Notice that a string shows up with quotes, because the prompt shows you the value, while print shows it the way a user would see it. For anything longer than a few lines, we use a .py file.
Python Culture
The Zen of Python
Python has a short list of guiding ideas called "The Zen of Python," written by Tim Peters, a long-time Python developer. It describes what good Python code should feel like.
You can see the whole list by typing this at the >>> prompt in real Python:
import this
A few of the lines:
Beautiful is better than ugly.
Simple is better than complex.
Readability counts.
There should be one-- and preferably only one --obvious way to do it.
What it means for you: write code other people can read easily. Use clear variable names like total_score instead of ts. Keep things simple. Your future self will thank you.
A hidden surprise:import this is called an "Easter egg": a fun secret built into Python. Try it at home in IDLE!
What a few lines mean in real code
Readability counts. Code is read many more times than it is written: by your teacher, your partner, and you next week. Compare:
a = 12 * 3 # hard to understand
total_cost = price * quantity # easy to understand
Simple is better than complex. If there is a short, clear way to do something, use it instead of a clever, confusing one.
Errors should never pass silently. (Another line from the list.) It is better for a program to stop with an error message than to quietly give a wrong answer. This is why Python stops and tells you when something goes wrong.
The Zen of Python: guiding ideas by Tim Peters.
Type import this to see all of them.
Readable names beat short, mysterious ones.
Every language has a personality, and Python's is written down. The Zen of Python says things like readability counts and simple is better than complex. That is a great rule for this class too: if your code is hard to read, there is probably a simpler way.
Practice
Check yourself
Choose an answer, then click Check. This is practice only. Nothing is graded or recorded.
How to get the most from these questions:
Pick your answer before looking at the choices closely, then see if it is listed.
When you miss one, find the slide it came from (use the Jump menu) and reread that part.
For questions about errors, ask: "Did Python find this before running (SyntaxError) or while running (runtime error)?"
Review the history slides and the "two kinds of stops" slide if you miss one.
These questions cover the story of Python and how it runs code. If you miss one, go back to that slide and read the explanation again.
Summary
Python at a glance
What it is
A high-level, general-purpose programming language
Interpreted and interactive
Free, open source, runs on Windows, macOS, and Linux
Where it came from
Created by Guido van Rossum at CWI in the Netherlands
Started December 1989, first released February 1991
Named after Monty Python's Flying Circus
Python 3: 2008. Python 2 retired: 2020
How it works
Source code (.py) is compiled to bytecode
The virtual machine runs it top to bottom
SyntaxErrors stop everything first; runtime errors stop at the bad line
Run it at the >>> prompt or as a .py script
Remember
We use Python 3. print always needs parentheses.
Python reads your whole file first. A SyntaxError means nothing ran.
The >>> prompt shows values automatically. A script needs print().
Readability counts: write code that other people can understand.
Key words to know
source code (what you write) · bytecode (Python's in-between form) · interpreter / virtual machine (what runs it) · SyntaxError (grammar mistake, nothing runs) · runtime error (problem found while running) · interactive mode (>>>) · script (.py file) · PEP (a proposal to change Python)
Let's wrap up. Python is a free, high-level language, created by Guido van Rossum starting in 1989 and named after a comedy show. When you run it, Python compiles your file to bytecode and the virtual machine runs it from top to bottom. Now you know the story behind every line we will write this year.