Results for “print function”

Showing 11–20 of 39

  1. Challenge

    Changed the caller's list

    …that were never really taken. Predict what the program prints, find out how the preview reached the stored list, fix the function, then write another one that leaves its input alone. Predict and run…

    Fix the code Medium 3 stages functions lists mutation return
  2. Challenge

    Sort by a field

    Sort launches by date with sorted() and a small function that returns each launch's date, then sort the cargo manifest heaviest first with a key function and reverse=True.

    Write the code Easy 2 stages functions sorted key reverse
  3. 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
  4. Challenge

    Clear error messages

    …noticed until the fuel budget came out 62.5 kg short. A function that gets a value it can't work with should say so, loudly and clearly, at the moment it happens. Raise ValueError Make fuel_needed()…

    Write the code Medium 2 stages errors raise ValueError TypeError
  5. Challenge

    Guard clauses

    The docking computer decides whether the ship may dock. Its function has grown one condition at a time, each inside the last, and the reason for a refusal now sits four levels deep, at the far end of…

    Fix the code Medium 2 stages functions return guard clauses refactoring
  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
  7. Challenge

    Any number of values

    …pass from the database, sometimes just two numbers. A function that wants a list makes every one of those calls a little clumsier than it needs to be. Write an average that takes the values as they…

    Write the code Easy 2 stages functions *args unpacking keyword-only arguments