Family edition
Moon Landing Lab: A Safe Spot at the South Pole, Searching Real Ground for a Landing
In Moon Landing Lab your child fixes a Python program that searches real Moon terrain for a safe landing spot, then flies it at the Moon's south pole, in shadows a camera cannot see into.
What you need
- A computer or Chromebook with a current browser.
- The link: mytekdev.com/try/moonlandinglab?lesson=a-safe-spot-at-the-south-pole-searching-real-ground&ref=fam-moonlandinglab-4. No account, no email and nothing to install.
Before you start: try it once yourself
Open mytekdev.com/try/moonlandinglab?lesson=a-safe-spot-at-the-south-pole-searching-real-ground&ref=fam-moonlandinglab-4. A short guide opens over Level 11, A safe spot. The Moon's gray ground fills the view in low sunlight, with Earth in the black sky. The lander hangs 500 m up. The readout gives the height, the speed (up or down), the throttle and the fuel. The box at the top says the level's goal and, after each run, what happened and why, with the run's own numbers. The strip under the scene draws the height and the speed as the lander comes down, with a line at 3.05 m/s, the fastest the legs take. On this level a colored strip on the ground shows the slope along the lander's line, and the readout adds how far the lander is from the start.
- The starter. Before the loop the program searches: for k from 0 to 30, it checks k x 5 m east, then k x 5 m west, and keeps the first spot where lander.slope_at() is under 20. It prints the spot. Then it flies there as Level 10 taught: lean toward it, come down slowly until it is over it, then land on the shrinking target speed. lander.target() counts from the start, so lander.target() + spot is how far the spot still is.
- Level 11. Play. The print reads "spot: 5 m east, slope 19.4 degrees", and the lander tips on 19.4 degrees after 51.0 seconds. Change 20 to 6: "spot: -55 m east, slope 3.5 degrees"; it lands on 3.9 degrees after 66.8 seconds, using 309 kg. The landing reads a little steeper than the spot because it touches down half a meter short.
- Level 12. Next. The same program at the south pole: "spot: -70 m east, slope 5.7 degrees"; it lands after 89.0 seconds on 410 kg. There is no colored strip here, and the camera cannot see into the shadows; slope_at() reads the map either way.
- Speed. Speed up and Slower, under the scene, change how fast time runs, up to 16 times. The landing comes out the same at any speed, because the program runs on the lander's own clock. The round play button runs the program from the start; the arrow beside it puts the lander back, hovering 500 m up. The descent has no randomness: the same program lands the same way on every run and every computer.
- Numbers to expect. Level 11 thresholds: 20 tips on 19.4; 15 tips on 14.7; 12 finds 50 m west and lands on 8.9 (307 kg); 6 lands 55 m west on 3.9 (309 kg); 3 lands 60 m west on 0.3 (310 kg). West to east under 6: 80 m west, 313 kg. The flattest: 60 m west, 310 kg. Level 12: 12 lands 50 m west on 11.4 (389 kg); 6 lands 70 m west on 5.7 (410 kg); 3 lands 90 m west on 2.8 (427 kg). West to east under 6: 150 m west, 473 kg, 103.1 s. The flattest: 105 m west on 1.8, 439 kg, 95.6 s. Steps of 1 m: 69 m west, 408 kg; steps of 20 m: 80 m west, 419 kg.
- West to east. In place of the four search lines: spot = None then for e in range(-150, 151, 5): then if spot is None and lander.slope_at(e) < 6: then spot = e (the if inside the loop, spot = e inside the if).
- The flattest. In place of the four search lines: spot = 0 then for e in range(-150, 151, 5): then if lander.slope_at(e) < lander.slope_at(spot): then spot = e (the if inside the loop, spot = e inside the if).
The ideas, in plain words
Both sites are real ground. The Apollo 11 site comes from the Lunar Reconnaissance Orbiter camera's terrain model, a height every 2 m. The south pole is the ridge between Shackleton and de Gerlache craters from the Lunar Orbiter Laser Altimeter's 5 m maps (Barker et al. 2021). Those maps give their own slope error as about 1.5 to 2.5 degrees, which is one reason to search for 6 and not 12. The Apollo Lunar Module's landing gear was designed for a mean slope of 6 degrees or less and 12 at most, the same numbers the app uses.
At the south pole the sun stays within a degree or two of the horizon, so shadows run for kilometers and some crater floors never see sunlight. A camera cannot judge slopes there; a laser can, and landers now carry ones that map the ground from hundreds of meters up. Slopes matter: in 2024 the IM-1 lander came down faster than planned on a slope of about 12 degrees, broke a leg and tipped over.
The search is a linear search, nearest first: each pass of the outer loop steps 5 m further out, and the inner loop checks east, then west. The guard spot is None keeps the first match. A loop from west to east is simpler to read but finds the westernmost match, not the nearest. Keeping the flattest is finding a minimum. With the guard, slope_at() is not called again once a spot is found; the flattest search calls it twice on every one of its 61 passes.
Guidance engineers write programs like these. The Apollo landing programs came from MIT's Instrumentation Lab, and their last phase held a descent rate the commander could step by 0.3 m/s. Aerospace engineers earned a median of $134,960 in May 2025 (U.S. Bureau of Labor Statistics), and guidance, navigation and control is one of their specialties.
Do it together
- Open mytekdev.com/try/moonlandinglab?lesson=a-safe-spot-at-the-south-pole-searching-real-ground&ref=fam-moonlandinglab-4 together and press play. Read the line that starts "print:".
You'll know it worked when: The search picks a spot 5 m east sloping 19.4 degrees. The lander lands on it and tips: the legs take 12.
- Open Python and change the 20 to 6. Go back to Simulator and play.
You'll know it worked when: The lander leans west, crosses 55 m and lands on 3.9 degrees.
- Press Next: Level 12 and play the same program.
If you get stuck: The south pole takes a moment to load the first time.
You'll know it worked when: In the long shadows, it finds a spot 70 m west, sloping 5.7 degrees, and lands, using 410 kg of fuel.
- Replace the four search lines with a search from west to east: for e in range(-150, 151, 5): with the same if inside. Play Level 12.
You'll know it worked when: It finds a spot 150 m west instead, and uses 473 kg: the farthest, and the most fuel.
- Now keep the flattest spot: start with spot = 0, and inside the loop keep e whenever lander.slope_at(e) < lander.slope_at(spot). Play Level 12.
You'll know it worked when: A 1.8 degree spot 105 m west, on 439 kg: flatter, but farther than nearest first.
Talk about it
Ask these while you work together. A child who has understood it can answer them without help:
- In the nearest-first search, which spots are checked on the third pass of the outer loop?
- What does spot is None do in the condition?
- Why is 6 a better threshold than 12, when the legs take 12?
- Why did west to east cost 63 kg more at the pole but only 4 kg more at the Apollo site?
- How can the program land safely where the camera cannot see?
For younger and older kids
Younger: For a younger child, stop after the south pole landing, and talk about why 6 is safer than 12.
Older: For an older child, change 6 to 1 at the pole and work out why the program stops with an error.
Keep going
- At the pole, a threshold of 1 finds no spot, and the program stops with an error. Change the program so it lands somewhere safe even then, and explain the choice.
- Change the steps from 5 m to 1 m and to 20 m. What does a finer search buy, and what does it cost?
- Open Level 13, On target, least fuel. Which parts of this program would you reuse there?
Bring it into other subjects
- Math: the slope is the angle of the ground. How many meters does ground sloping 12 degrees rise over 10 m? (10 x tan 12, about 2.1 m.)
- Earth science: why does the sun stay so low at the Moon's poles? Compare the Moon's tilt with Earth's.
- Engineering: list what makes a landing site good besides slope: boulders, sunlight for power, a view of Earth for radio.
- Careers: look up what a planetary scientist who makes maps from spacecraft data does.
For your records
Ready to copy into an hour log, a portfolio or a transcript.
| Lesson | Moon Landing Lab: A Safe Spot at the South Pole, Searching Real Ground for a Landing |
|---|---|
| Subjects | Computer science |
| Time | 45 minutes |
| What we did | Fixed and extended a Python search that finds a safe landing spot on real Moon terrain: chose a safe slope threshold, landed at the south pole, and compared three search algorithms by fuel, distance and safety margin. |
| Skills practiced | Search algorithms; Nested loops; Comparing solutions |
Moon Landing Lab: A Safe Spot at the South Pole, Searching Real Ground for a Landing
Activity sheet (optional)
Name: ______________________________ Date: ______________
Open the app: scan the QR code, or go to mytekdev.com/try/moonlandinglab?lesson=a-safe-spot-at-the-south-pole-searching-real-ground
Essential question: How can a program choose a safe place to land on ground it cannot see?
Warm-up: Parking a bike on a dark hill with a flashlight that shows only the ground under you: how do you find a flat spot? ________________________
- Vocabulary. Slope, linear search, threshold, nested loop, hazard map, tradeoff: write each in your own words.
- Trace it. The spots checked on passes k = 0, 1 and 2: ________________________.
- Level 11 and Level 12. Under 20: spot ____, slope ____, result ____. Under 6 at Level 11: spot ____, landed on ____ degrees, ____ kg. Under 6 at Level 12: spot ____, ____ degrees, ____ kg.
- Three searches. West to east: one loop, for e in range(-150, 151, 5):, with the same if inside. The flattest: spot = 0, then one loop from -150 to 150 that keeps e whenever lander.slope_at(e) < lander.slope_at(spot). Level 11, fuel: nearest ____ west to east ____ flattest ____. Level 12, spot and fuel: nearest ____ west to east ____ flattest ____.
1. Why is 6 a safer threshold than 12?
2. Which search would you fly at the pole, and what does it give up?
Quick check
Name: ______________________________
1. The nearest-first search checks 0, then 5 and -5, then 10 and -10. Which spot does it check next? (A) 15 (B) -15 (C) 20
2. Without spot is None in the condition, the nearest-first search would keep: (A) the first match (B) the last match, the farthest one (C) no match at all
3. A friend says the west-to-east search is just as good, because it cost only 4 kg more at the Apollo site. Use what you learned today to answer.
Answers
| Question | Answer | Why |
|---|---|---|
| 1 | A | The next pass of the outer loop is k = 3: it checks 15 m east first, then -15. |
| 2 | B | Every later match would overwrite spot, so it ends at the last one found, the farthest out. |
| 3 | Open answer | One test is not enough: at the pole west to east found a spot 150 m away and used 63 kg more than nearest first. Compare algorithms on several cases. |
If your state or umbrella school asks, this lesson covers CSTA 2017 3A-AP-15, CSTA 2017 3B-AP-10, NGSS HS-ETS1-4.
Moon terrain in the pictures: NASA/GSFC/Arizona State University (LROC NAC terrain model and orthophoto of the Apollo 11 site); the south pole: NASA LOLA team (NASA/GSFC), Barker et al. 2021, LOLA 5 m site maps.