Challenge
Undo and history
Extend the working cargo console: record every change to the hold in a history list and show it with a history command, then add undo, which takes the last change off the history and reverses it.
Showing 11–20 of 22
Challenge
Extend the working cargo console: record every change to the hold in a history list and show it with a history command, then add undo, which takes the last change off the history and reverses it.
Example
Python allows changing variable type during program execution. This is dynamic typing.
Challenge
…67.0 kg crew: 3.4 kg Start with totals = {} . For each record, totals.get(category, 0) gives the total so far, or 0 for a category not seen yet; add the record's mass and store it back under the…
Article Mini projects
…dose in {wait_seconds // 3600:.1f} hours" # Dispense and record self.dose_times.append(current_monotonic) return "DISPENSED: Medication delivered safely" # Grace tries his trick: dispenser =…
Example
Adding, changing and removing dictionary elements in Python.
Quiz
…functions need to take any number of values: a log that records every reading, a launch that accepts optional settings, a helper that passes everything on to another function. In Python, *args…
Challenge
…each value, in order. A new field The manifest now also records the module each item is stowed in. The starter code stops with ValueError: too many values to unpack , because the tuple has four values…
Challenge
The mission log records thousands of lines a day, and the flight director only wants to see the errors. Before the log viewer can highlight them, it has to know whether a line contains ERROR , and…
Example
Dictionaries can contain other dictionaries. Useful for complex data structures.
Example
Dictionaries store data as key-value pairs. Fast access to data by key.