Results for “if”

Showing 31–40 of 100

  1. Article Mini projects

    Base 6 Number System in Python

    If you've read Andy Weir's Project Hail Mary , you probably remember (spoiler alert!) the moment when Ryland Grace tries to communicate with Rocky, the alien engineer from the 40 Eridani star system…

  2. Challenge

    Copy-pasted blocks

    …with for name, level in tanks: and keep one copy of the if / else , with name in place of the letter. A fourth tank A fourth tank has been fitted. Add tank_d = 9.75 under tank_c and one more pair to…

    Fix the code Medium 2 stages refactoring for loop tuples lists
  3. Article Mini projects

    Calculate your weight on different planets in Python

    …a planet. Time to calculate and display the weight: if chosen_planet in planets: gravity = planets[chosen_planet] weight = calculate_weight(mass, gravity) print(f"Your weight on {chosen_planet} would…

  4. Challenge

    Clear error messages

    …length can't be negative: {burn_s} s") inside an if , before the calculation. A burn of 0 seconds is allowed. Raise TypeError A burn length read from a file arrives as the text "40" , and the function…

    Write the code Medium 2 stages errors raise ValueError TypeError
  5. Challenge

    Line to record

    …every record, print only the records of the wanted sensor. If there are none, say so: Records: 4 ENG-2 at 09:30:05: 412.5 C ENG-2 at 09:30:10: 415.0 C With wanted = "GYRO-X" , the last line is No…

    Write the code Easy 2 stages dictionaries lists parsing records
  6. Challenge

    Retry the uplink

    …3 Start delay_s = 2 before the loop. After a failure, if attempt < MAX_ATTEMPTS , print the wait and double delay_s . (The simulator only prints the wait; real code would call time.sleep(delay_s) .)

    Write the code Medium 2 stages for loop range break retry