Challenge
Log line format
…line from them: [T+00:12:05] INFO Engines nominal A plain {minutes} prints 12 , but {seconds} prints 5 , not 05 . Add a format spec after a colon: {seconds:02} means "at least 2 characters wide…
Showing 21–30 of 38
Challenge
…line from them: [T+00:12:05] INFO Engines nominal A plain {minutes} prints 12 , but {seconds} prints 5 , not 05 . Add a format spec after a colon: {seconds:02} means "at least 2 characters wide…
Article Python Fundamentals
…# km "inclination": 51.6, # degrees "period": 92.68, # minutes } # Crew roster crew_members = [ "Sarah Connor", "John Smith", "Maria Garcia", "Yu Chen" ] # Mission checkpoints (immutable)…
Example
Multiple conditions with elif. Checking several possibilities in sequence.
Challenge
The monitoring system raises the same alert over and over. Group repeats of an alert that come within 60 seconds of the first into one line with a count, in the order they first appeared, then add the…
Challenge
readings[5] on a list of five readings stops with an IndexError. Predict it, work out the valid indexes with len(), fix it with [-1], then print the first, middle and last readings for any length.
Example
The else block executes when if condition is not met. Two possible paths.
Challenge
Extend the OK/WARN/CRITICAL check from Alert level so a for loop runs it over every temperature in a list, then count the WARN and CRITICAL readings for a summary line.
Example
Python allows changing variable type during program execution. This is dynamic typing.
Example
Local variables exist only inside functions. Global ones are accessible everywhere.
Example
Changing data types using int(), float() and str() functions. Converting between types.