Results for “unpacking”

Showing 1–10 of 12

  1. Challenge

    Manifest line

    …the tuple has four values and only three names. Fix the unpacking and add the module to the line: CG-0042 | Water filter cartridges | 18.5 kg | Node 2

    Write the code Easy 2 stages tuples unpacking ValueError formatting
  2. 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
  3. Challenge

    Names with values

    Print each sensor name with its reading by looping over two lists together with zip(), then add a third list of units and warn when the lists don't have the same length, since zip() quietly stops at…

    Write the code Easy 2 stages for loop zip lists unpacking
  4. Challenge

    Parse the whole feed

    Go through a block of telemetry line by line with splitlines(), split each line at the commas and print the sensor and value, then unpack the four fields and show the clock time too.

    Write the code Easy 2 stages for loop splitlines split unpacking
  5. Challenge

    Landing site

    Store the Perseverance landing site as a (lat, lon) tuple, unpack it into two variables in one line and print both to four decimals, then show it the way maps do, with N, S, E and W.

    Write the code Easy 2 stages tuples unpacking formatting coordinates
  6. Challenge

    Survive bad lines

    …operator, so it is skipped too. One try, with the reason Unpacking a line with too few fields raises ValueError too. Drop the length check and let one try cover both the unpacking and the conversion…

    Write the code Medium 2 stages errors try except ValueError