# The line starting with # is a comment. Python ignores it
print("Welcome to your food-delivery startup!")
print("Stickers bought:", 1200) # commas print several things, a space betweenWelcome to your food-delivery startup!
Stickers bought: 1200
Programming with Python

I really appreciate active participation and interaction!
Materials live on Moodle and are hosted at python.tobiasvlcek.com.
.py file and upload it to MoodleThe weekly lab exercises rehearse exactly this routine. Do them, and the checkpoints will feel familiar.
Learning the basics without AI first is what lets you judge AI output later.
uv) and the Zed editor on your own laptop, together in class; from Session VIII the labs run on your machineCmd/Ctrl+Enter (or the play button at its edge). The output appears right below it# YOUR CODE BELOW; the check under each exercise updates by itselftotal in two and both turn redCmd/Ctrl+S, then menu (top right) → Download → Download Python code. The tab remembers you until you close it; the download is foreverWhy now? From Session VI you get Zed’s paid editor plan for free as a student, and Zed only accepts GitHub accounts that are at least 30 days old. In Session X your project lives on GitHub. Nothing else to install until Session VII.
This semester you are founding a campus food-delivery startup. Today it gets a name, a menu, and its first revenue calculation.
(Your co-founder Tobi has already spent the marketing budget on stickers.)
Today your startup’s first program does three small things: record the founding data, do one calculation, and print a summary.
print()print() is a function: you hand it something, it shows it on screen.
# The line starting with # is a comment. Python ignores it
print("Welcome to your food-delivery startup!")
print("Stickers bought:", 1200) # commas print several things, a space betweenWelcome to your food-delivery startup!
Stickers bought: 1200
=: name on the left, value on the rightcompany_founded = 2026 # store a whole number under a name
print(company_founded)2026
Store the facts of the new company, then use them by name:
company_founded = 2026
first_employee = "Tobi" # co-founder, but he put himself on the payroll first
sticker_budget = 300 # what's left after Tobi's spending spree
print(first_employee)
print(sticker_budget)Tobi
300
Tobi spends another 50 EUR of the budget. What does the last line print?
sticker_budget = 300
sticker_budget = sticker_budget - 50
print(sticker_budget)a) Error b) 300 c) 250
Predict. Pick a letter, then I reveal the answer.
sticker_budget = 300
sticker_budget = sticker_budget - 50
print(sticker_budget)250
c) 250: the right side is computed first (300 - 50), then the name is pointed at the new value. A name always shows its latest value.
_budget and Budget are two different namesfor, if, def, …)Question (we solve this together, out loud): Which of these are valid variable names?
sticker_budget, 1st_employee, firstEmployee, company-name, _tobi
Tobi’s grand plan: sell everything for 9.99. To see whether that survives contact with arithmetic, we need Python’s operators.
# margin = price - cost
print(9.99 - 7.40)2.59
print(9.99 + 1.50) # addition
print(9.99 - 7.40) # subtraction
print(9.99 * 3) # multiplication
print(300 / 8) # division, always gives a float11.49
2.59
29.97
37.5
// and %: how many fit, what’s left// floor division: how many whole times something fits% modulo: the remainder left over# The 300 EUR budget, boxes at 7 EUR each
print(300 // 7) # whole boxes we can buy
print(300 % 7) # EUR left over
print(10 // 2.5) # 4.0: floor division on floats floors, but returns a float42
6
4.0
* and / happen before + and -. Parentheses override that.
print(2 + 3 * 4) # 14, not 20
print((2 + 3) * 4) # 2014
20
Tobi buys 12 boxes at 25 EUR from the 300 EUR budget. What prints?
print(300 - 12 * 25)a) 0 b) 7200 c) Error
Predict. Pick a letter, then I reveal the answer.
300 - 12 * 25print(300 - 12 * 25)0
a) 0: 12 * 25 = 300 happens first, so the budget is wiped out. Reading left to right would give 7200, but Python follows precedence, not reading order.
Two friends split a 10 EUR order. What prints?
print(10 / 2)a) 5.0 b) 5 c) Error
Predict. Pick a letter, then I reveal the answer.
10 / 2print(10 / 2)5.0
a) 5.0: / always returns a float, even when the division comes out even. For a whole number, use //.
int + int stays an int; / always produces a floatint and a float gives a floatmargin = 9.99 - 7.40
print(margin)
print(type(margin))2.59
<class 'float'>
round(): clean moneyDivision can leave a long tail of decimals. round(value, 2) keeps two. Cents.
# Split a 10 EUR order three ways
print(10 / 3) # 3.3333333333333335, ugly
print(round(10 / 3, 2)) # 3.33, a proper amount3.3333333333333335
3.33
A string is text in quotes. Single or double quotes both work, just be consistent.
item = "Miso Ramen"
print(item)
print('Tobi shouts "9.99!"') # mix quotes to include a quote insideMiso Ramen
Tobi shouts "9.99!"
You can glue strings with +, but numbers must be converted first, and it gets clumsy fast:
qty = 2
item = "Miso Ramen"
total = 23.00
print(str(qty) + "x " + item + ": " + str(total) + " EUR")2x Miso Ramen: 23.0 EUR
(str(...) turns a value into text, which is clumsy. We’re about to see the better way.) Forget one str() and Python stops with a TypeError.
Tobi stored two order quantities as text and adds them up. What prints?
print("3" + "4")a) Error b) 34 c) 7
Predict. Pick a letter, then I reveal the answer.
"3" + "4"print("3" + "4")34
b) 34: with quotes, these are strings, and + on strings glues them together. To add numbers, drop the quotes (or convert with int()).
Put an f before the quote and write values in { }, and Python fills them in:
qty = 2
item = "Miso Ramen"
total = 23.00
print(f"{qty}x {item}: {total} EUR")2x Miso Ramen: 23.0 EUR
No str(), no +. Just the sentence you want.
Download your .py before you leave. Closing the tab without downloading loses your work, and downloading is exactly how you hand in the checkpoints.
str, int, float, bool)* and / before + and -; round(x, 2) for money{value:.2f} turn numbers into clean receipt linesNext time, Episode 2: the city bans delivery after 22:00, and Tobi suggests “we just deliver yesterday’s orders.” We’ll need conditionals and loops to survive it. Plus an ungraded 15-minute practice checkpoint before the lab.
Think Python is a great book to start with and is free online. Schrödinger programmiert Python is a playful German-language alternative with lots of examples.
For more, see the literature list of this course.