Results for “if”

Showing 51–60 of 63

  1. Challenge

    Duplicate events

    Print each capsule event once, keeping the first copy, by checking every ID against a set of IDs already seen, then report which IDs came in more than once.

    Write the code Medium 2 stages sets add in deduplication
  2. Challenge

    Debris grid

    Scan a radar grid stored as a list of strings with a loop inside a loop, print the row and column of every # with enumerate(), then turn the loops around to find the columns that are clear all the way…

    Write the code Medium 2 stages nested loops enumerate range strings
  3. Challenge

    Filter the log

    Go through the mission log and build a new list holding only the WARN and ERROR entries with append(), then let a minimum level decide what counts, the way logging tools filter by severity.

    Write the code Medium 2 stages for loop lists append filtering
  4. Challenge

    First error

    Scan the mission log for the first ERROR entry, print its line number with enumerate() and stop there with break, then report how many lines were checked, or that there were no errors at all.

    Write the code Easy 2 stages for loop break enumerate flags
  5. Challenge

    Skip blanks and comments

    Extend the feed parser so continue skips blank lines and comment lines, then report damaged lines with too few fields instead of crashing, with a count of parsed and damaged lines.

    Write the code Medium 2 stages for loop continue strip startswith
  6. Challenge

    input() returns text

    A crew count read with input() crashes when 1 is added to it. Predict the crash, find out what input() really returns, fix it with int(), then write a packing tool that reads two numbers.

    Fix the code Easy 3 stages input int TypeError type conversion
  7. Challenge

    Names with values

    …101.2 kPa zip() takes three lists as easily as two. But if one list is shorter, it stops early without a word, and a reading goes missing from the display. Before the loop, check that the three…

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

    Landing site

    …Site: 18.4447° N, 77.4508° E Choose each letter with an if : 0 and above is N or E, below 0 is S or W. abs() gives a number without its sign. Curiosity's landing site, (-4.5895, 137.4417), would be…

    Write the code Easy 2 stages tuples unpacking formatting coordinates