Challenge
Magic numbers
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.
Showing 1–10 of 11
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.
Challenge
…find the leg that doesn't fit, convert it with a named constant, then convert a lander's feet per second to metres.
Challenge
…by speed. The speed of light is already in the code as a constant, in kilometres per second. Minutes and seconds Nobody talks about a delay of 750.5 seconds. Show it as whole minutes and seconds…
Challenge
Ask for an engine burn length with input(), turn it into a number with float() and work out the propellant it uses, then read the tank level too and show what the burn leaves.
Example
Tuples are immutable lists. Once created, they cannot be modified.
Example
Learning to import modules in Python. Modules extend your program capabilities.
Article Mini projects
…# 6.371 × 10⁶ (6,371,000 meters) gravity_constant = np.float64(6.674e-11) # 6.674 × 10⁻¹¹ (very small number) # NumPy handles these numbers efficiently print(f"Earth's mass: {earth_mass}") # Will…
Example
Parameters allow passing data to functions. Functions become more flexible.
Quiz
…str and bool Type conversion with int() and dynamic typing Constants by convention and the global keyword How it works 15 questions: 11 with one correct answer, 4 where you select every correct answer…
Challenge
…over several passes. Add PASS_S = 600 next to the other constant and print how many passes the file needs: Downlink time: 27 min 47 s Ground station passes: 3 A download that takes exactly 30 minutes…