Challenge
Log to a file
The mission log has lived in a Python list, which disappears the moment the program ends. Tomorrow's shift wants to read what happened today, and the flight director wants a file she can send to the…
Showing 81–90 of 92
Challenge
The mission log has lived in a Python list, which disappears the moment the program ends. Tomorrow's shift wants to read what happened today, and the flight director wants a file she can send to the…
Quiz
…changing global variables, and the global keyword Why a list can be changed without global , and where UnboundLocalError comes from Blocks such as if and for , which have no scope of their own, and…
Article Python Fundamentals
…five, calls get hard to read and easy to get wrong. A long list of parameters is often a sign that the function is trying to do too many jobs. When you really do need several, keyword arguments make…
Challenge
…COMMS Signal weak (x2) Keep the groups as dicts in a list, groups , with first , last , source , message and count , and a dict from (source, message) to the newest group for that alert. to_seconds()…
Challenge
…valid (the number of readings), rejected and the alerts list, written with json.dump() , indent=2 and ensure_ascii=False . Then print one last line: Saved summary.json The hidden tests open…
Challenge
…Check one action for one crew member, then the whole list of airlock actions. One action Check that the crew member holds every permission in needed . If not, print what is missing, sorted: Kowalska…
Challenge
…reach 60 dB, and the loop would run past the end of the list. Wait while there are readings left and the strength is below LOCK_DB , then print where the signal locked, or that it never did: No lock…
Challenge
…CABIN: 101.2 kPa ENG-2: 415.0 C feed.splitlines() gives a list with one string per line. Inside the loop, line.split(",") gives the four fields, as in "Parse a telemetry line". Named fields and the…
Challenge
…without the spaces around it but with its capitals, and list the commands that work: Type a command: start, stop or status Unknown command: Launch (use start, stop or status) Keep the typed text in…
Article Mini projects
…CALCULATION WITH NUMPY") print("="*50) names = list(planets.keys()) masses = np.array([planets[p]["mass"] for p in names]) radii = np.array([planets[p]["radius"] for p in names]) # Calculate all…