Start Here: Your Mission
By the end of this unit you will design and build RoboForge — a program that manufactures virtual robots as objects, gives each one its own unique specifications, and manages your whole fleet. Every stage teaches you a tool you will need for the final build.
Setup Choose your workshop
Option A — IDLE (school computers)
- Open IDLE (Python 3.14) from the Start menu.
- The window that opens is the Shell — great for quick experiments.
- For real programs, go to File → New File to open the Editor.
- Save your file with a .py ending, then press F5 to run it.
Option B — Online (any device)
- Go to online-python.com.
- Type your code in the editor on the left.
- Press the green Run button.
- Output and input() prompts appear in the console below.
First run Prove your workshop works
Type this into a new editor file and run it:
print("RoboForge systems online.") name = input("Enter engineer name: ") print("Welcome to the factory floor, " + name)
Two commands do almost everything at this stage: print() sends text out to the screen, and input() brings text in from the keyboard.
- SyntaxError — check every bracket ( ) and quote mark " " has a matching partner.
- Nothing happens — in IDLE, make sure you saved the file and pressed F5 in the editor window, not the Shell.
- NameError — Python is case-sensitive: Print is not the same as print.
Task 1.1 Engineer ID badge
Write a program that asks for your name, your favourite piece of technology, and your engineer call-sign (a nickname), then prints a three-line ID badge using that information.
Variables & Data Types
A variable is a labelled box in the computer's memory. RoboForge will eventually need to store dozens of values — robot names, battery levels, armour ratings — so this stage is your foundation.
Learn Creating variables
robot_name = "VX-9" # str — text (a string) battery = 87 # int — whole number top_speed = 14.5 # float — decimal number is_active = True # bool — True or False
- str = string — text data: letters, words and symbols wrapped in quote marks.
- int = integer — a whole number, positive or negative, with no decimal point.
- float = floating point value — a number that can hold a decimal point.
- bool = boolean — a value that can only ever be True or False.
Naming rules for this class: use snake_case (lowercase words joined with underscores), start with a letter, and choose names that describe the value. battery_level beats b every time.
Predict What will each snippet print?
Decide your answer before revealing. Then test it in your editor to confirm.
A)
x = 5 y = x + 2 x = 10 print(y)
B)
print("10" + "5")
C) This one is tricky — you have not been taught it yet, so just have a guess at what you think the answer will be.
print(7 / 2) print(7 // 2)
Learn f-strings: the clean way to print
An f-string lets you drop variables straight into text using curly braces:
robot_name = "VX-9" battery = 87 print(f"Robot {robot_name} is at {battery}% charge.")
Output: Robot VX-9 is at 87% charge. — you will use f-strings constantly in RoboForge.
Learn input() always gives you a string
Even if the user types 42, input() hands you the text "42". To do maths with it, convert (cast) it first:
battery = int(input("Battery level: ")) battery = battery + 10 # now this works
Use int() for whole numbers and float() for decimals.
Checkpoint quiz — Variables
Answer every question to unlock the assess button.
Task 2.1 Robot spec sheet
Write a program that asks the user for a robot's name (str), weight in kg (float), and year built (int). Then print a spec sheet using f-strings, including the robot's age calculated from the current year.
Conditional Statements
Conditionals let your program make decisions. A real robot checks its battery before starting a job — your RoboForge robots will do the same.
Learn if, elif, else
battery = int(input("Battery %: ")) if battery >= 80: print("Fully operational.") elif battery >= 30: print("Operational — recharge soon.") else: print("Critical! Return to dock.")
- Python checks conditions top to bottom and runs the first one that is True.
- The colon : and the 4-space indent are not optional — indentation is how Python knows which lines belong to each branch.
- elif and else are optional; if can stand alone.
Learn Comparison and logical operators
| Operator | Meaning | Example (True) |
|---|---|---|
| == | equal to (two signs — one = assigns!) | 5 == 5 |
| != | not equal to | "on" != "off" |
| > < >= <= | greater / less than (or equal) | 10 >= 10 |
| and | both sides must be True | battery > 30 and is_active |
| or | at least one side is True | mode == "eco" or battery > 50 |
| not | flips True/False | not is_docked |
Predict Trace the logic
Decide your answer before revealing. Then test it in your editor to confirm.
A)
score = 70 if score > 50: print("Pass") if score > 60: print("Credit")
B)
x = 5 if x = 5: print("five")
C)
temp = 25 if temp > 20 and temp < 30: print("Safe operating range")
Checkpoint quiz — Conditionals
Answer every question to unlock the assess button.
Task 3.1 Diagnostic scanner
Write a program that asks for a robot's battery % and core temperature. Report:
- "READY" if battery ≥ 50 and temperature is between 10 and 45
- "CHARGE FIRST" if only the battery is the problem
- "COOLING REQUIRED" if only the temperature is the problem
- "FULL SERVICE" if both fail
Loops
Loops repeat code so you don't have to. A factory that builds one robot is a workshop; a factory with a loop is a production line.
Learn for loops and range()
for unit in range(5): print(f"Assembling robot unit {unit}")
This prints units 0 to 4 — range(5) gives five numbers starting at 0 and stopping before 5.
| Call | Produces |
|---|---|
| range(5) | 0, 1, 2, 3, 4 |
| range(1, 6) | 1, 2, 3, 4, 5 |
| range(0, 20, 5) | 0, 5, 10, 15 (step of 5) |
| range(10, 0, -1) | 10, 9, 8 … 1 (counting down) |
Learn while loops
A while loop keeps running as long as its condition is True. Perfect when you don't know in advance how many repeats you need — like a charging cycle:
battery = 20 while battery < 100: battery = battery + 15 print(f"Charging... {battery}%") print("Charge complete.")
Learn The accumulator pattern
One of the most useful ideas in programming: start a total at zero, then add to it inside a loop.
total_weight = 0 for unit in range(3): weight = float(input("Robot weight (kg): ")) total_weight = total_weight + weight print(f"Total cargo: {total_weight} kg")
Predict Trace the loop
Decide your answer before revealing. Then test it in your editor to confirm.
A)
for i in range(3): print(i * 2)
B)
n = 1 while n < 20: n = n * 2 print(n)
C)
total = 0 for i in range(1, 5): total += i print(total)
Checkpoint quiz — Loops
Answer every question to unlock the assess button.
Task 4.1 Launch sequence + production line
Part A: use a for loop with range() to print a countdown from 10 to 1, followed by "LAUNCH".
Part B: ask the user how many robots to build, then use a loop to print a serial number for each one (e.g. RF-001, RF-002 …).
Lists & Arrays
So far each variable holds one value. A list holds a whole collection under one name — exactly what you need to manage a fleet of robots instead of a single machine.
Learn Creating and reading lists
fleet = ["VX-9", "Titan", "Scout-3", "Nova"] print(fleet[0]) # VX-9 — indexing starts at 0! print(fleet[3]) # Nova print(fleet[-1]) # Nova — negative counts from the end (there is no such thing as -0) print(len(fleet)) # 4 — how many items
Learn Changing lists
| Code | What it does |
|---|---|
| fleet.append("Bolt") | adds to the end |
| fleet.insert(0, "Alpha") | adds at a position |
| fleet.remove("Titan") | removes the first match by value |
| fleet.pop() | removes (and returns) the last item — or give it a position, e.g. removed_2nd_item = fleet.pop(1) |
| fleet[1] = "Titan-II" | replaces an item |
| "Nova" in fleet | True/False membership check |
| fleet.sort() | sorts alphabetically / numerically |
Loop through a list with the pattern you already know:
for robot in fleet: print(f"{robot} reporting for duty")
Learn Lists vs arrays — what's the difference?
Other languages you may meet later (C#, Java, JavaScript) use arrays: fixed-size collections where every item is usually the same type. Python's list is a more flexible version — it can grow, shrink, and mix types. Python does have a stricter array module and libraries like NumPy for high-performance number crunching, but for this course (and most Python programs), the built-in list is the tool for the job. If an exam or textbook says "array", in Python you can read that as "list".
Predict Trace the list
Decide your answer before revealing. Then test it in your editor to confirm.
A)
nums = [4, 8, 15] nums.append(16) print(len(nums))
B)
bots = ["A", "B", "C"] print(bots[len(bots) - 1])
C)
total = 0 for n in [10, 20, 5]: total += n print(total)
Checkpoint quiz — Lists
Answer every question to unlock the assess button.
Task 5.1 Fleet roster (mini-RoboForge)
This task rehearses the structure of your final assessment. Build a program with an empty list called fleet and a menu inside a while loop:
=== ROBOFORGE FLEET ROSTER === 1. Add a robot 2. View all robots 3. Remove a robot 4. Quit
- Add asks for a name and appends it.
- View loops through the list and prints each robot with its position number.
- Remove asks for a name, checks it exists with in, then removes it (or prints an error).
- Quit ends the loop politely.
RoboForge: Fleet Management System
Everything comes together. You will build an object-oriented program that manufactures robots as objects, uses inheritance to create specialised robot types, stores unique parameters for every robot built, and manages the whole fleet in a list.
New tools Classes and objects in five minutes
A class is a blueprint. An object is one real thing built from that blueprint. Your class defines the attributes (data every robot stores) and methods (things every robot can do).
class Robot: def __init__(self, name, battery): self.name = name # attributes: each object keeps self.battery = battery # its own copy of these values def status(self): # a method return f"{self.name}: {self.battery}% charge" # Building objects — each has its own unique parameters: r1 = Robot("VX-9", 87) r2 = Robot("Nova", 42) print(r1.status()) # VX-9: 87% charge print(r2.status()) # Nova: 42% charge
- __init__ runs automatically whenever an object is created — it is the assembly line.
- self means "this particular object". self.name is this robot's name.
New tools Inheritance: specialised robots
A child class inherits everything from its parent, then adds or changes what makes it special:
class BattleBot(Robot): # inherits from Robot def __init__(self, name, battery, armour): super().__init__(name, battery) # run the parent's setup self.armour = armour # new attribute for this type def status(self): # overriding the parent's method return f"{self.name} [ARMOUR {self.armour}]: {self.battery}%" b1 = BattleBot("Titan", 95, 80) print(b1.status()) # Titan [ARMOUR 80]: 95%
- super().__init__() calls the parent's constructor so you don't repeat yourself.
- Redefining a method in the child is called overriding — the child's version wins.
- A BattleBot is still a Robot, so it fits in the same fleet list as any other robot.
Brief Your task
Design and build a console program that manages a fleet of robots. Your finished system must:
- Define a base class Robot with at least three attributes (e.g. name, battery, weight) and at least two methods (e.g. status(), recharge()).
- Define at least two child classes (e.g. BattleBot, ScoutBot, MedicBot) that use super().__init__(), add at least one unique attribute each, and override at least one method.
- Let the user manufacture robots through a menu, entering unique parameters for each one — every object in your fleet should hold its own data.
- Store every object in a single fleet list, and let the user view the full fleet, search for a robot by name, and remove a robot.
- Run the menu in a while loop with input validation (bad menu choices and impossible values are handled without crashing).
Scaffold Starter structure
You may start from this skeleton. The comments are your to-do list — the design decisions are yours.
class Robot: def __init__(self, name, battery, weight): # store the parameters as attributes ... def status(self): # return a one-line summary string ... def recharge(self): # set battery back to 100 and confirm ... class ScoutBot(Robot): def __init__(self, name, battery, weight, sensor_range): # call super().__init__ then add sensor_range ... fleet = [] while True: print("\n=== ROBOFORGE ===") print("1. Manufacture robot") print("2. View fleet") print("3. Search by name") print("4. Remove robot") print("5. Quit") choice = input("Choose: ") # handle each choice — remember input validation!
Milestones Build order & progress tracker
Tick milestones off as you complete them. Work in this order — each step is testable on its own. (Progress resets when the page is closed, so use it within a lesson.)
- M1 — Base Robot class works: create two robots in code and print both statuses.
- M2 — First child class inherits with super().__init__() and adds a unique attribute.
- M3 — Second child class added; at least one method is overridden.
- M4 — Menu loop runs and quits cleanly.
- M5 — Manufacture option builds an object from user input and appends it to the fleet list.
- M6 — View fleet loops the list and calls each object's status().
- M7 — Search and remove by name both work, including the "not found" case.
- M8 — Input validation: wrong menu numbers and invalid values are handled without crashing.
Rubric How your work will be assessed
| Criterion | Developing | Consolidating | Extending |
|---|---|---|---|
| Classes & objects | A base class is defined and at least one object is created with attributes. | Base class has multiple attributes and working methods; several objects are created, each storing its own unique parameters. | Class design is clean and well-justified; methods return values (not just print); attributes are used consistently through the program. |
| Inheritance | One child class inherits from the base class. | Two or more child classes use super().__init__(), add unique attributes, and override at least one method. | Inheritance clearly reduces repeated code; overridden methods extend parent behaviour meaningfully; mixed types work seamlessly in one fleet. |
| Data management (lists) | Objects are stored in a list and can be displayed. | Fleet list supports add, view, search and remove, using loops and membership checks correctly. | Fleet operations handle edge cases (empty fleet, duplicates, missing names) gracefully; output is well-formatted. |
| Program control & validation | A menu loop runs and responds to at least some choices. | Menu loop handles every option, quits cleanly, and validates menu input. | All user input is validated (including numeric conversions); the program cannot be crashed by ordinary user behaviour. |
| Code quality | Code runs with some meaningful variable names. | snake_case naming, sensible structure, and comments explaining key sections. | Consistently clear, well-commented code; thoughtful decomposition; f-strings used for all output formatting. |
Submit Submission checklist
- My .py file runs from a fresh start without errors.
- My name and class are in a comment at the top of the file.
- I have tested manufacturing at least one robot of every type.
- I have tested searching and removing, including a name that does not exist.
- I have uploaded my file for assessment before the due date.
Solutions
This section contains worked solutions for every task, every Stretch extension, and the major assessment. It is locked with a keyword.