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…
Showing 61–70 of 202
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…
Challenge
…and a default, then print a list of launches with defaults for any missing field.
Challenge
…when the battery is under 20% or contact has been lost for over 10 minutes, using or, then name the rule that fired with boolean variables and an if/elif chain.
Challenge
…how print() ends. A Python challenge on print(end=...) for progress messages.
Challenge
…it returns and what the reserve means, then add type hints for its parameters and return value; the tests read both from the function itself.
Quiz
…surprises almost every beginner runs 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…
Quiz
…in every program. This free quiz has 15 short questions for beginners: how to create and name a variable, what happens when you assign one variable to another, which data type a value has, how to…
Challenge
…in Mbit/s with input(), work out the transfer time without forgetting the 8 bits in a byte, show it in minutes and seconds, then count the ground station passes.
Challenge
Extend format_log() from "Log formatter function" with **fields, so any extra keyword arguments are added to the line as key=value pairs, then pass whole dicts of fields into it with ** at the call.
Quiz
…where UnboundLocalError comes from Blocks such as if and for , which have no scope of their own, and list comprehensions, which do Nested functions, the nonlocal keyword and the order in which Python…