Challenge
Live T-minus
…before launch, and at launch itself, and T+ after it, then print countdown(launch, datetime.now(timezone.utc)) . With the clock stopped five minutes after launch, the check expects: T+00:05:00 Pick…
Showing 61–70 of 79
Challenge
…before launch, and at launch itself, and T+ after it, then print countdown(launch, datetime.now(timezone.utc)) . With the clock stopped five minutes after launch, the check expects: T+00:05:00 Pick…
Challenge
Write convert(), which looks a unit pair up in a table of factors, works the other way round by dividing, and refuses unknown units or missing pairs with a clear ValueError, then extend the table with…
Article Mini projects
…how to do it. Converting Decimal to Base 6 - Your Own Function The algorithm is straightforward: keep dividing the decimal number by 6 and collect the remainders. Those remainders, read in reverse…
Article Mini projects
…the Cosmic Dice Now comes the exciting part! Let's write a function that randomly selects our destination: def select_random_destination(): # Choose a random planet destination =…
Challenge
…from "Telemetry pipeline" has been split into small functions, ready for the ground station to run unattended. Before it goes live, the team wants tests: whoever changes the pipeline next must find…
Quiz
…type a value has, how to convert between types and when a function can change a variable outside it. What the quiz covers Creating variables and the rules for their names Reassigning, copying a value…
Article Mini projects
…each pair are separated by a colon. Next, let's create a function to calculate weight: def calculate_weight(mass, gravity): return mass * gravity This function multiplies mass by gravity to get…
Article Mini projects
…hack in action: dispenser = NaiveMedicationDispenser() print(dispenser.request_dose(datetime.now())) # First dose works print(dispenser.request_dose(datetime.now())) # Denied - too soon # The "clever"…
Article Python Fundamentals
…= travel_time + surface_operations + return_time print(f"Total Mars mission duration: {total_mission_time} days") # Calculating remaining fuel (liters) initial_fuel = 1000000 used_fuel = 850000…
Example
Functions enumerate() and range() extend for loop capabilities in Python.