Programming with Python
Kühne Logistics University Hamburg - Fall 2026
I really appreciate active participation and interaction!
Materials live in the KLU portal and are hosted at beyondsimulations.github.io/Introduction-to-Python.
.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, the Zed editor)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 Kevin 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.
Welcome to your food-delivery startup!
=: name on the left, value on the right2026
Store the facts of the new company, then use them by name:
Kevin
300
_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, _kevin
Every value has a type, which decides what you can do with the value:
str — text, in quotes: "Kevin", "Falafel Wrap"int — whole numbers: 2026, 300float — decimal numbers: 9.99, 0.15bool — truth values: True, Falsetype()type() tells you the type of any value, and it’s priceless when a bug surprises you:
<class 'int'>
<class 'str'>
<class 'float'>
Kevin typed the price with quotes. What does this print?
a) <class 'float'> b) <class 'int'> c) <class 'str'>
Predict first. Commit to an answer before the next slide.
type("9.99")c) str — the quotes make it text, however numeric it looks. Kevin’s “price” can’t be multiplied until it is converted to a number.
<class 'str'>
Open the exercise (scan the QR or type the link):
beyondsimulations.github.io/Introduction-to-Python/notebooks/ex_01_a/
First predict what happens, then run it.
Kevin’s grand plan: sell everything for 9.99. To see whether that survives contact with arithmetic, we need Python’s operators.
5.79
11.49
5.79
29.97
37.5
// and %: how many fit, what’s left// floor division: how many whole times something fits% modulo: the remainder left over42
6
4.0
* and / happen before + and -. Parentheses override that.
14
20
Kevin buys 12 boxes at 25 EUR from the 300 EUR budget. What prints?
a) 0 b) 7200 c) Error
Predict first, then turn the page.
300 - 12 * 25a) 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.
0
int + int stays an int; / always produces a floatint and a float gives a float5.79
<class 'float'>
round(): clean moneyDivision can leave a long tail of decimals. round(value, 2) keeps two. Cents.
3.3333333333333335
3.33
Open the exercise (scan the QR or type the link):
beyondsimulations.github.io/Introduction-to-Python/notebooks/ex_01_b/
First predict what happens, then run it.
A string is text in quotes. Single or double quotes both work, just be consistent.
Miso Ramen
Kevin shouts "9.99!"
You can glue strings with +, but numbers must be converted first, and it gets clumsy fast:
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 raises a TypeError.
Put an f before the quote and write values in { }, and Python fills them in:
2x Miso Ramen: 23.0 EUR
No str(), no + — just the sentence you want.
:.2fInside the braces, :.2f forces two decimals, exactly what a receipt needs:
23.0 EUR
23.00 EUR
Python stores 23.00 as the number 23.0. Only you know it’s money, and :.2f says so.
\n\n inside a string starts a new line: one string, several lines.
Falafel Wrap: 6.90 EUR
Pad Thai: 8.90 EUR
What does each line print?
a) 6 and 6 b) 6 and 2 * 3 c) 2 * 3 and 2 * 3
Predict first, then reveal.
f"{2 * 3}" vs "2 * 3"b) 6 and 2 * 3 — the f-string evaluates what’s in the braces; plain quotes keep the text literal. The f and the { } are what do the work.
6
2 * 3
Open the exercise (scan the QR or type the link):
beyondsimulations.github.io/Introduction-to-Python/notebooks/ex_01_c/
First predict what happens, then run it.
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 Kevin suggests “we just deliver yesterday’s orders.” We’ll need conditionals and loops to survive it.
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.
Lecture I - Introduction | Dr. Tobias Vlćek | Home