Results for “python return”

Showing 41–50 of 78

  1. Article Python Fundamentals

    Variables and data types in Python

    …# Common reserved keywords include: False class finally is return None def for lambda try True del from nonlocal while and elif global not with as else if or yield break except import pass Example of…

  2. Challenge

    Shared default list

    …Work out how many samples a third call without a log would return, and store it in third_count . Remove any lines you added before you check. Modify. Give each call without a log its own new list. It…

    Fix the code Medium 3 stages functions default values mutable defaults None
  3. Challenge

    Test the parser

    …for good lines: compare the whole record parse_line() returns with the dict you expect, so every field and its type are checked. When they all hold, print: All checks passed For example, a line from…

    Write the code Medium 2 stages testing assert parsing None
  4. Challenge

    Unit converter

    …pair the other way round, divide; for the same unit twice, return the value. Raise ValueError for a unit the table doesn't know, unknown unit: ... , or for two known units with no factor between them…

    Write the code Medium 2 stages project dictionaries tuples as keys functions
  5. Challenge

    Confirm by name

    …can only be passed by name and can't be left out, and return the refusal when it isn't true. The calls print: ABORT: Cabin pressure falling Abort refused: pass confirm=True With the * in place…

    Write the code Medium 2 stages functions keyword-only arguments * safety
  6. Challenge

    Command parser

    …. It ignores case and the spaces around words, returns ("burn", seconds) for a burn with one positive number, and raises ValueError with the reason for anything else. Then try every command and print…

    Write the code Medium 2 stages project parsing strings split
  7. Challenge

    Read the traceback

    A Python program stops with a 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
  8. Challenge

    Legacy script

    …keeping the output exactly as it is now: parse_feed(feed) returns a dict from each sensor to its list of values, as floats, in order; summary_line(sensor, values) returns one report line: the average…

    Fix the code Hard 2 stages project refactoring functions testing
  9. Challenge

    Launch schedule digest

    …Cargo 4 (NASA) A small function such as window(launch) , returning the parsed datetime, works for the comparison and as the key for sorted() . strftime("%Y-%m-%d %H:%M") formats a datetime. Time left…

    Write the code Medium 3 stages project json datetime timedelta
  10. Challenge

    Manifest validator

    …go. Every problem, per item Write problems(item) , which returns a list of everything wrong with one item: each field from REQUIRED that is missing, in that order, then a mass that is not a number, is…

    Write the code Medium 2 stages project validation dictionaries functions