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…
Showing 31–40 of 78
Article Mini projects
…# 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…
Quiz
…this one, try the Python Functions Quiz or the Python Return Values Quiz .
Quiz
…into: a second name for the same list, and methods that return None . What the quiz covers Indexing from the front and the back, slicing, len() and in Changing items, append() , insert() and extend()…
Quiz
…0, + will not join text and a number, and string methods return a new string instead of changing the old one. This free quiz has 15 short questions on working with strings in Python. What the quiz…
Quiz
…a program forgets to. What the quiz covers What input() returns, including when the user just presses Enter Converting text with int() and float() , and which text raises a ValueError Numbers kept as…
Article Python Fundamentals
…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…
Challenge
…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.
Article Mini projects
…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…
Challenge
…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.
Challenge
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…