Kurse › Raspberry Pi › Stufe 5
Raspberry Pi · Einsteiger · Stufe 5 / 40
Python Foundations on the Pi
Write, run and debug small Python 3 programs inside a virtual environment.
Einsteiger freischalten · CHF 9.90 Stufen 1–13, einmalig, kein Abo
10 Lektionen in dieser Stufe
- Running Python in Thonny and from the Terminal
Start a Python program three ways and know when to use each. · Lab: Run the same two-line program in the Thonny shell, as a Thonny script and with python3 in the terminal. - Variables, Numbers and Strings
Store values, do arithmetic and build text with f-strings. · Lab: Write a unit converter that turns Celsius into Fahrenheit and prints a formatted sentence. - Making Decisions with if, elif and else
Branch a program on comparisons and combined conditions. · Lab: Classify a temperature as cold, comfortable or hot and handle the boundary values correctly. - Repeating Work with for and while Loops
Repeat actions a fixed number of times or until a condition changes. · Lab: Print a countdown, then loop until the user types "stop". - Lists, Tuples and Dictionaries
Group related values and look them up by position or by key. · Lab: Store five readings in a list, compute min, max and mean, and keep sensor names in a dictionary. - Writing and Calling Your Own Functions
Package logic into functions with parameters and return values. · Lab: Refactor the converter and the statistics code into three reusable functions. - Reading and Writing Text Files in Python
Open files safely with the with statement and write CSV rows. · Lab: Append a timestamped line to a CSV file each time the script runs and read the file back. - Handling Errors with try and except
Read a traceback and keep a program running through expected failures. · Lab: Make the converter survive text input, a missing file and division by zero. - Importing Modules and Using the Standard Library
Use time, datetime, pathlib, random and subprocess instead of rewriting them. · Lab: Read the CPU temperature from /sys with pathlib and time-stamp it with datetime. - Virtual Environments and pip on Bookworm
Create a venv, install packages into it and explain the "externally managed" message. · Lab: Create a venv with --system-site-packages, install a package with pip and prove the system Python is untouched.
Abschlussprojekt
A command-line health reporter that reads CPU temperature, memory and disk use, appends them to a CSV file and prints a warning when a limit is crossed.
Teile für diese Stufe
- 1 × Raspberry Pi 5 or Pi 4 set from Level 1
In jeder Lektion legst du die passenden Teile direkt in den Warenkorb. Raspberry Pi →
Voraussetzung: Level 4: terminal use, editing files and working over SSH.