Challenge
Flatten nested ifs
…reports the first one it finds; GO goes in the else at the end: Docking: HOLD, closing speed too high Docking: HOLD, misaligned Docking: HOLD, latches not ready Docking: GO Check the speed first, then…
Showing 61–70 of 75
Challenge
…reports the first one it finds; GO goes in the else at the end: Docking: HOLD, closing speed too high Docking: HOLD, misaligned Docking: HOLD, latches not ready Docking: GO Check the speed first, then…
Challenge
…then compare it in an if / elif chain, with else at the end. Helpful errors Make the errors helpful. For an empty answer, ask for a command; for an unknown one, repeat what was typed, without the…
Challenge
At the end of each orbit, the flight director reads a summary of the mission log: how many entries, and how many of them are warnings. A sudden jump in warnings is often the first sign that something…
Challenge
…plus its length, plus one for the space, and leave the end out. The time in brackets can grow longer, [T+100:02:00] , so work from position , not from a fixed number.
Challenge
…formatter". The order matters: round the seconds at the end instead, and a delay of 779.7 seconds turns into "12 min 60 s". Round trip A command can't be confirmed until the reply comes back, so…
Challenge
…Most of the time they agree. When they don't, a crate can end up a kilogram lighter on paper than on the scales. Predict where they differ, investigate a rule that surprises most programmers, then…
Article Mini projects
…The displayed number might not show exact zeros at the end due to floating-point precision, but NumPy's float64 provides excellent accuracy for our calculations. Breaking Down the Problem into Steps…
Challenge
…each attempt, stop at the first "ok" , then say how it ended: Attempt 1: timeout Attempt 2: no carrier Attempt 3: ok Uplink sent on attempt 3 When all three fail, the last line is Uplink failed after…
Challenge
…name.split() splits on any run of spaces and drops the ends, so " ".join(...) rebuilds it neatly; title() capitalises each word. Reject and deduplicate Build the crew list. Reject a sign-up with no…
Challenge
…an hour every Sunday, and twice this month somebody ended up working a night shift straight after an afternoon. Let the program build the rota, and check its own work. In turn Build rota , a list of…