Lecture 07 · Python
Inheritance explorer
Pilot a rover, trace a call, or build one of the shapes from class. Follow the same object as Python looks for its next method.
Lecture 7 Inheritance
Where does super() go?
A scout rover prints commands for a photo survey. Camera and Radio both inherit from Rover. All three define survey().
Python excerpt
scout = Scout()
scout.survey()
Inside Camera, which survey() does super() call?
Printed commands in order
Make a prediction, then run the survey.
See the full Python program
More Lecture 7 activities
Rover rescue
Pilot one rover with a hazard shield and a cargo rig. Both classes define enter(). Their order decides whether the rig can collect a sample in a storm.
Changing builds restarts the mission. Edit this roverField mission Sector 07
Crystal recovery
Collect crystals at two different sites, then reach the lander before the battery runs out.
Four rows run from A to D and six columns run from 1 to 6. The rover starts at C1. There are sample sites at A3, C2 and C5, and the lander is at C6. C2 is a storm. Use the direction buttons or focus the map and use arrow keys.
Pilot console
At the landing site
Preparing the rover.
Use the buttons, tap an adjacent tile, or focus the map and press an arrow key.
Inspect the method callsTrail
Route hint
The storm crystal is one step east of the start. For a sheltered route, go north to row A and collect the crystal at A3. Both routes pass another crystal at C5, just before the lander.
Python dispatch
Where does super() go?
super().enter(tile) keeps the same rover as self. It looks for enter after the class whose method is running, following this rover’s class order.
Move the rover or compare a build to inspect one turn.
Class lookup order
Choose a class to inspect its part in this turn.
Predict
Call replay
See the whole call path
Compare all builds on the same storm sample
Each build enters the same tile from launch with 12 energy. Choose a build below to inspect that recorded move.
| Build | Cargo rig receives | Base calls | Cargo | Energy left |
|---|
Edit the rover classes and create your own rover
Try swapping the two bases in class RescueRover(...). Launch your version and drive east onto the storm sample to test your prediction.
Make a shape
Set its dimensions and color. Then choose a method and predict where Python finds it.
Where does this fruit belong?
Choose an object, then test its type or try a method from the lecture. Follow the path to see which classes it inherits from.
Apple defines makeAppleCider(). Orange defines makeOrangeJuice().
What will Python print?
Arrows point to base classes
Object attributes
Printed output
Source code
Change a class, method or object creation line, then run your version.