← Back to course
Code Crew G6+ / Week 12 / Friday
5/6
Week 12 Β· Ship and demo

Friday

Graduation
// Test, polish, snapshot, graduate
⏱ about 30 min

Friday: Graduation

The lights in Mission Control dim, and the big screen shows a list of twelve weeks. Every program the crew wrote is there, from a single print line to Mission Log.

Rocket reads the list from the top. "Hello, Mission Control," he says, laughing. "I remember being amazed that the shell answered 2 plus 3."

Raven reads from the bottom. "What do you notice?" she asks. "Every week used the weeks before it. Mission Log has a piece of every single one."

Nova rises above the crew and her lights burst into a slow spiral of cyan and gold. "Great discovery," she says softly. "You did not just learn Python. You learned how to learn the next thing."

Rocket and Raven turn to the screen and read out one last line together.

Twelve weeks in Mission Log

WeekYou learnedWhere it lives in Mission Log
1print, comments, reading errorsComments at the top, every message
2variables, input, f-stringsadd_entry and format_entry
3if, elif, elseThe menu choices
4loops and breakwhile True and break in main
5lists and dictionariesEach entry, and the list of entries
6functions and modulesEleven functions, imported by the tests
7the standard librarydate.today() for each entry
8files and withopen in load_entries and save_entries
9JSONmission_log.json
10try, except and assertload_entries and test_mission_log.py
11decomposing a projectThe plan and the menu
12edge cases, snapshots, demosmission_log_v1.py and your demo
FINAL REVIEW
  • Read the question.
  • Tap your answer.
What does input() always give back?
Which file mode adds to the end without erasing?
Where do you start reading a traceback?
What makes import mission_log skip the menu?
What is the index of the first item in a Python list?
Which keyword hands a value back from a function?
At your computer
1. Open your mission folder in the file browser. Count the .py files you have written.
2. In IDLE, open hello_mission.py from week 1 and run it with F5.
3. Open test_mission_log.py and run it. Check that every test still passes.
4. Run mission_log.py and add a final entry with the tag idea, describing what you will build next.
Mission Commander
You built a real command-line tool in Python: planned, coded, tested, fixed, documented, snapshotted and demoed.
That is the same cycle professional programmers follow, every day.
Congratulations, Mission Commander.

Where to go next

  • Explore more of the standard library. The statistics module can find averages and middles for you.
  • Add a feature to Mission Log, like deleting an entry. Save a snapshot first, and write a test.
  • Rebuild an old program, like the quiz or the countdown clock, using functions and a test file.
  • Read other people's code and predict what it does before you run it.
For a grown-up
Your learner has finished Code Crew: Mission Commander. Ask them to show you their mission folder and explain three of the programs in it.
Everything they need to keep going is already installed: Python and IDLE, with no extra packages.

One last challenge

Before the final Crew Quest, read this program and predict its output. It uses ideas from almost every week of the course.

# final_review.py
def busiest(counts):
    """The tag with the highest count."""
    best = ""
    for tag, n in counts.items():
        if best == "" or n > counts[best]:
            best = tag
    return best

tags = ["build", "test", "build", "idea"]
counts = {}
for tag in tags:
    counts[tag] = counts.get(tag, 0) + 1
print(counts)
print("Busiest tag:", busiest(counts))
PREDICT FINAL_REVIEW.PY
  • Read the question.
  • Tap your answer.
What is counts["build"] after the loop?
What does the last line print?
Why does best start as an empty string?
You add "test" twice more to tags. What is the busiest tag now?
How many keys does counts have?
What does busiest({}) return? (describe it in one word)
Which week taught counts.get(tag, 0) + 1? Week ____
StatementTrue or false?
busiest returns a value instead of printing it.?
The docstring changes what busiest does.?
for tag, n in counts.items() gives each key and value.?
This program needs a file to run.?
You could test busiest with assert busiest({"a": 1}) == "a".?
WHY THIS EXERCISEbusiest returns its answer so it can be tested, and the program uses no files at all.

You did it. Every line of Mission Log is yours. Tomorrow is the final Crew Quest.

← Thursday