Space Python Loading Python…

Creating Variables

 
0:00 / 0:00

Challenge

Practise what this example shows with these challenges.

Mission config

Write the codeEasy 3 stages

Predict, investigate and extend a mission config held in variables: text, whole numbers, decimals and True/False. A PRIMM challenge on Python data types.

Start the challenge

Magic numbers

Fix the codeEasy 3 stages

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.

Start the challenge

Names that explain

Fix the codeEasy 3 stages

A cargo calculation uses a, b, x2 and tmp. Predict it, work out what each name holds, rename them so the code explains itself, then write a fuel check with good names.

Start the challenge

Running totals

Write the codeEasy 3 stages

Predict how -= and += change a fuel level, track it through three burns and a top-up, then follow a battery through one orbit. A PRIMM challenge on updating variables.

Start the challenge

Discussion

Stuck on this example or want to go further? Ask here, or see what others asked.

Log in to ask and reply.

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:].