Results for “functions”

Showing 1–10 of 39

  1. Challenge

    Log formatter function

    …mission log's f-string into format_log(t, level, msg), a function that returns the line instead of printing it, then fix the alignment of every log line with one change inside the function.

    Fix the code Easy 2 stages functions def return refactoring
  2. Challenge

    Parser function

    …in one place and not the other. Turn the parsing into a function that any program can call, then let it decide on its own which lines are worth a record. parse_line() Move the parsing of one line into…

    Fix the code Medium 2 stages functions return dictionaries None
  3. Challenge

    Summary function

    …the ones where the sensor sent nothing. Write one function that returns the whole summary, then make it safe for an empty pass. Four numbers in one dict Write summarise(readings) , which returns a…

    Write the code Medium 2 stages functions return dictionaries min
  4. Challenge

    Read the traceback

    …Read it from the bottom up to find the error, the function and the line, fix the bug there, then follow a longer traceback through four calls to a second bug.

    Fix the code Easy 2 stages errors traceback KeyError TypeError
  5. Challenge

    Extra log fields

    Extend format_log() from "Log formatter function" with **fields, so any extra keyword arguments are added to the line as key=value pairs, then pass whole dicts of fields into it with ** at the call.

    Write the code Medium 2 stages functions **kwargs keyword arguments dictionaries
  6. Challenge

    Test the alert levels

    The engine alert check from "Alert level" is now a function, alert_level() , and other programs depend on it. Before anyone changes it again, it needs tests: small checks that run in a second and…

    Write the code Medium 2 stages testing assert functions boundaries