Results for “python loops”

Showing 21–30 of 57

  1. Article Mini projects

    Calculating Escape Velocity in Python

    …to Earth: {ratio:.2f}x") def main(): """Main program loop.""" print("Welcome to the escape velocity calculator!") print("Powered by NumPy for accurate scientific calculations") while True…

  2. Challenge

    One orbit short

    A loop over range(1, 10) logs nine orbits of a ten-orbit flight. Predict the last line, find out where range() stops, fix it with ORBITS + 1, then list every third orbit with a range() step.

    Fix the code Easy 3 stages for loop range off-by-one step
  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

    Skip blanks and comments

    …CABIN: 101.2 kPa 09:30:10 ENG-2: 415.0 C At the top of the loop, strip the line, then continue when it's empty or starts with # . Stripping first matters: one comment is indented, and a line can hold…

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

    Check every reading

    Extend the OK/WARN/CRITICAL check from Alert level so a for loop runs it over every temperature in a list, then count the WARN and CRITICAL readings for a summary line.

    Write the code Easy 2 stages for loop lists if elif
  6. Challenge

    Parse the whole feed

    …line, and a parser has to handle every line the same way. Loop over the lines, split each one, and print what the flight controllers need. Line by line Go through the feed line by line, split each…

    Write the code Easy 2 stages for loop splitlines split unpacking
  7. Article Python Fundamentals

    Python Books for Beginners

    …shapes and creating simple animations while learning loops and functions, which keeps things visually interesting. The math isn't overwhelming either - basic algebra is enough for most examples. Fair…

  8. Challenge

    Filter the log

    …ERROR Fuel valve 2 still closed Start with alerts = [] , loop over the log, and append() each line that contains "] WARN" or "] ERROR" . The log itself must stay complete. A minimum level Make the…

    Write the code Medium 2 stages for loop lists append filtering
  9. Article Python Fundamentals

    Python Functions for Beginners

    …answer should be 430. Because return sits inside the for loop, the function ends during the very first pass. Move it back one level so it lines up with for : def total_fuel(tanks): total = 0 for tank…