Challenge
Shadowed fuel
…assigns to fuel_kg inside the function, creating a local variable and leaving the global fuel unchanged. Predict the last line, compare both values, fix it by returning the total, then write a…
Showing 11–20 of 53
Challenge
…assigns to fuel_kg inside the function, creating a local variable and leaving the global fuel unchanged. Predict the last line, compare both values, fix it by returning the total, then write a…
Challenge
…a battery through one orbit. A PRIMM challenge on updating variables.
Challenge
…using or, then name the rule that fired with boolean variables and an if/elif chain.
Quiz
…15) to pass You can try each idea in a runnable example: variable arguments with *args , variable keyword arguments with **kwargs , combining argument types and positional and keyword arguments…
Challenge
Unpack an (id, item, mass_kg) tuple into three named variables and print a cargo manifest line, then fix the ValueError when the manifest adds a fourth field.
Example
Tuple unpacking assigns its elements to separate variables simultaneously.
Challenge
…check the exact boundaries, then store the level in a variable for a status line.
Article Python Fundamentals
…differently. Common Beginner Mistakes Mistake 1: Same Variable Names # BAD - inner loop overwrites x! for x in range(3): for x in range(3): # ← Overwrites outer x print(x) Python won't throw an error…
Challenge
Turn the bare 9.81 and 1000 in a weight report into named constants without changing the output, then write a Mars version with constants from the start.
Article Mini projects
…secret. Set MEDICATION_DISPENSER_SECRET environment variable for production.") return secret def _compute_hmac(self, message): """Compute HMAC-SHA256 of message using device secret""" return hmac.new(…