Results for “if”

Showing 21–30 of 100

  1. Challenge

    Approved payloads

    …list Strip the spaces and make it upper case, then use if with in . For " pl-117 " it prints the first line.

    Write the code Easy 2 stages lists in membership if
  2. Challenge

    Lookup table

    Replace a nine-branch elif that maps planets and the Moon to surface gravity with a dict and one get() lookup, keeping the output exactly the same, then loop over the dict for a weight table.

    Fix the code Medium 2 stages dictionaries refactoring lookup tables get
  3. Challenge

    Numbered checklist

    Print a pre-flight checklist numbered from 1 with enumerate(list, start=1), then tick off the items the crew has already done with [x] and leave the rest as [ ].

    Write the code Easy 2 stages for loop enumerate start lists
  4. Article Mini projects

    Medical dispenser - Don’t trust the user

    …# Trust whatever time is given (or system time) if current_time is None: current_time = datetime.now() # Check if enough time has passed if self.dose_history: last_dose = self.dose_history[-1]…

  5. Article Mini projects

    Calculating Escape Velocity in Python

    …a ball upward. It always falls back down, right? But what if you threw it so hard that it never came back? That's escape velocity - the minimum speed needed to break free from a planet's gravity…

  6. Article Mini projects

    Managing Astronaut Medical Data with Python

    …above the content of this article. Feel free to peek ahead if you're curious, but we recommend following along step-by-step for the best learning experience! 1. Setting Up Our Python Environment…

  7. Article Python Fundamentals

    Nested Loops in Python

    …for scan_y in range(10): for scan_x in range(10): # Check if there's a rover at this position rover_found = None for x, y, name in lost_rovers: if x == scan_x and y == scan_y: rover_found = name break…

  8. Challenge

    Flight software review

    …0.0-450.0 Look at the decision line it prints after that. If it seems wrong to you, you are right: that is the fifth bug, for stage 2. This stage checks the lines above. Make it right ENG-2 is over…

    Fix the code Hard 2 stages project debugging SyntaxError TypeError
  9. Challenge

    Test the pipeline

    …whoever changes the pipeline next must find out at once if something broke. Write them. The hidden tests plant three bugs, one at a time, and your tests must catch every one. Test parse_row() Write…

    Write the code Hard 2 stages project testing assert try
  10. Article Python Fundamentals

    Python Functions for Beginners

    If you've written even a few lines of Python, you've already used functions. print() is one. So are len() , input() and int() . Somebody wrote them, gave each one a name, and now you can use them…