Space Python Loading Python…

Mission config

Write the codeEasy 3 stages

Before every flight, the mission software loads a config: the mission's name, how many people are on board, how much fuel is loaded and whether this is only a dry run. Each setting is a different kind of value, and Python treats each kind differently.

This challenge works in three steps. First you predict what some code prints and run it. Then you investigate how it works and modify it. Finally you make something similar yourself.

Don't run the code yet. Read it and decide what it will print. Write your guess in prediction, at the top, between the quotes. Then run it and compare.

Any guess passes this stage: the point is to think before you run. After you check, you'll see your prediction next to what Python printed.

Look closely at how each kind of value will appear: the crew size, the fuel load and the dry-run flag.

Predict, then run
Leave the program as it is

Finish stage 1 to unlock this stage.

Investigate. Every value has a type: int for whole numbers, float for decimals, str for text and bool for True/False. Replace each ... with the type of that value, for example crew_type = int. You can check with print(type(crew)), but remove that line again before you check.

Modify. Add a launch_site variable holding the text "Esrange" and put it into the summary, so the program prints:

Perseid: crew 4, fuel 12.5 t, from Esrange, dry run True
Name the type of each value
Add the launch site

Finish stage 2 to unlock this stage.

Now write a config yourself. Store the four settings of a rover test drive in variables with the names given in the comments, each with the right type, then print them one per line:

Rover: Pathfinder-2
Wheels: 6
Battery: 3.6 kWh
Autonomous: False
Print the rover config
Give each setting the right type
You're not logged in, so your progress is kept in this browser only. Log in to save it, and to use hints and solutions.

Hints

Creating Variables

creating-variables-python.py
# Variables store data under a name
# Create them by assigning a value with =

ship_name = "Project Hail Mary"
crew_count = 3
fuel_remaining = 78.4
in_deep_space = True

print("Ship:", ship_name)
print("Crew:", crew_count, "people")
print("Fuel remaining:", fuel_remaining, "%")
print("In deep space:", in_deep_space)
Open the full example
script.py
PythonLn 1, Col 1Spaces: 4
Loading the Python environment…

Separate arguments with commas. They're passed on every Run as sys.argv[1:].