Results for “python return”

Showing 31–40 of 78

  1. Article Mini projects

    Python Random Module

    …# Get planet details planet_info = planets[destination] return destination, planet_info # Let's try our space lottery! planet, details = select_random_destination() Making It More Interesting What if…

  2. Article Python Fundamentals

    Python If/Else for Beginners

    …to orbit insertion burn.") else: print("Abort burn — return to safe orbit.") Think of it this way: if is mission go; else is the contingency plan. elif — multiple checkpoints elif (short for "else…

  3. Challenge

    Sort by a field

    …launches by date with sorted() and a small function that returns each launch's date, then sort the cargo manifest heaviest first with a key function and reverse=True.

    Write the code Easy 2 stages functions sorted key reverse
  4. Article Mini projects

    Medical dispenser - Don’t trust the user

    …wait_time = self.minimum_interval - time_since_last return f"ACCESS DENIED: Wait {wait_time.seconds // 60} more minutes" # Check daily limit (also vulnerable!) today_doses = [d for d in…

  5. Challenge

    Test the error

    …when fuel_needed(-5) raises ValueError, so a version that returns a value or raises the wrong error fails it, then pin down the message and the lengths that must still work.

    Write the code Medium 2 stages testing assert try except
  6. Challenge

    Clear error messages

    fuel_needed() quietly returns negative fuel for a negative burn length. Make it raise ValueError with a message that shows the bad value, then raise TypeError, checked first, when the length isn't a…

    Write the code Medium 2 stages errors raise ValueError TypeError