ROBOTICS AND CODING MODULE

Python Fundamentals

Structuring text-based programmes through variables, conditions, loops, collections, functions, files and error messages.

Last updated: 27 July 2026
MODULE IDENTITY

The distinctive work of this module

Structuring text-based programmes through variables, conditions, loops, collections, functions, files and error messages.

Completion evidence: Working Python programme, sample inputs, expected outputs and failure tests.

Write a small input-validating programme split into functions; test at least three valid and three invalid inputs.

Core production

Working Python programme, sample inputs, expected outputs and failure tests

Laboratory

Write a small input-validating programme split into functions; test at least three valid and three invalid inputs.

Safety / limit

Record power, wiring, data or user limits on hardware, and model limitations in simulation.

LESSON SEQUENCE

A 15-step learning pathway

The order is recommended. Before a project page, complete evidence from foundation, practice and debugging lessons.

01 · Variables and Data Types

Learn to assign variables and work with int, float, str and bool types and type conversion.

Open lesson →

02 · Getting Started with Files

Learn to read and write text files safely using with open. An in-depth guide to Getting Started with Files with practical examples, safety notes and explained review activities.

Open lesson →

03 · Functions

Learn to define functions with def and reuse code with parameters and return.

Open lesson →

04 · For and While Loops

Learn repetition with for and while loops, using range, break and continue.

Open lesson →

05 · Your Setup and First Program

Learn how to run Python, the indentation rules, and how to write your first small program.

Open lesson →

06 · Reading Error Messages

Learn to read Python error messages (traceback, error type, line) calmly and fix them.

Open lesson →

07 · Conditions in Python

Learn to make decisions in Python with if / elif / else and logical operators.

Open lesson →

08 · Getting Input from the User

Learn to read input with input(), convert text to numbers and print output with f-strings.

Open lesson →

09 · Lists and Dictionaries

Learn to store and traverse ordered data with lists and key-value data with dictionaries.

Open lesson →

10 · Modules and Libraries

Learn to use modules with import and standard libraries like math, random and datetime.

Open lesson →

11 · Project: Simple Sports Statistics

Build a program that computes total, average and maximum from sample training data and prints a summary.

Open lesson →

12 · Project: Timetable Check

Use dictionaries and lists to build a program that lists lessons and books for a chosen day.

Open lesson →

13 · Project: Number Guessing Game

Combine random, while, if and input to build a working number guessing game.

Open lesson →

14 · What Is Python and Where Is It Used?

Learn what Python is, why it is readable and versatile, and where it is used in web, data, AI and robotics.

Open lesson →

15 · Randomness and Simple Game Logic

Learn to create randomness with the random module and build simple game logic like dice and rock-paper-scissors.

Open lesson →
EVIDENCE MATRIX

Four checks before saying it works

Four checks before saying it works table
CheckQuestionEvidence to keep
InputWhich value, event or user request enters the system?Sample inputs and edge cases
ProcessWhich rule, algorithm or physical relationship is applied?Code, calculation, diagram or state table
OutputWhat should be observed in correct and incorrect states?Expected–actual comparison
SafetyUnder which condition should the system stop or request help?Safe-stop and recovery behaviour
MODULE-SPECIFIC DEPTH

Python Fundamentals: from one example to a system

Structuring text-based programmes through variables, conditions, loops, collections, functions, files and error messages. A correct example alone is therefore insufficient. Completion evidence should be working python programme, sample inputs, expected outputs and failure tests, tested with normal, boundary and invalid inputs.

In the first cycle, pair foundation and application among Getting Started with Files, Functions, For and While Loops, Your Setup and First Program, Reading Error Messages. Predict the result, run or measure it, then explain any difference. Even when prediction and reality match, state which changed condition would break the result.

In the second cycle, complete this laboratory: Write a small input-validating programme split into functions; test at least three valid and three invalid inputs. Do not close with one successful screenshot. Keep the input table, expected behaviour, actual behaviour, error or measurement and the correction in one file.

In the final cycle, connect Project: Simple Sports Statistics, Variables and Data Types, Conditions in Python, What Is Python and Where Is It Used?, Randomness and Simple Game Logic. Let one lesson's output become another lesson's input; show where safe stopping is needed when data type, unit, wiring, timing or user expectation changes.

Repeat the same task one month later with less source support. Compare not only speed or appearance but test coverage, explainability, safety and whether another person can rebuild the work.

CROSS-LESSON BRIDGE

How do Getting Started with Files and Randomness and Simple Game Logic connect?

Use the foundation produced in Getting Started with Files as an input to Modules and Libraries. Then show in Randomness and Simple Game Logic how the same idea changes under the limits of a larger system. This bridge carries the goal of structuring text-based programmes through variables, conditions, loops, collections, functions, files and error messages. beyond one isolated example.

Add three columns to the working python programme, sample inputs, expected outputs and failure tests file: knowledge carried from the previous lesson, condition changed in the new lesson and result observed in testing. Sharing a word does not establish a connection; one lesson’s output should genuinely become the next process’s input.

Test the connection through this laboratory: Write a small input-validating programme split into functions; test at least three valid and three invalid inputs. After the first attempt, add an edge condition such as empty data, wrong type, disconnected input, extreme value or user error. Record whether the system remains understandable and safe beyond the normal example.

  • Name the previous lesson output
  • State the one changed condition
  • Separate expected and actual result
  • Define safe stopping or error feedback
  • Make one change in the second version
MICRO QUIZ

Test the reasoning behind the module

1. What is the module completion evidence?

Working Python programme, sample inputs, expected outputs and failure tests

2. Does a simulator replace hardware testing?

No. A simulator tests logic; physical power, wiring and sensor conditions require separate tests.

3. Which four fields belong in an error log?

Condition, expected result, actual result and change made.

4. When should the project page be opened?

After completing foundation concepts and at least one practice artefact.

5. What is the module mini laboratory?

Write a small input-validating programme split into functions; test at least three valid and three invalid inputs.

PRIMARY SOURCES

Verify versions and tool behaviour

Python Tutorial

Primary source for current technical behaviour and limits.

Open source →

Python Library Reference

Primary source for current technical behaviour and limits.

Open source →