Exercises appear regularly in the book. Just like the concept checks, these exercises will check your understanding of the topics in this chapter. They also provide good practice for the new skills.
Unlike the concept checks, you will need a code editor to complete the exercises. Fortunately, you created a free account on Repl.it as part of the prep work.
Here is the starter repl.it link.
Use the information given below about your space shuttle to complete the exercises:
Data | Value |
---|---|
Name of the space shuttle | Determination |
Shuttle Speed (mph) | 17,500 |
Distance to Mars (km) | 225,000,000 |
Distance to the Moon (km) | 384,400 |
Miles per kilometer | 0.621 |
Declare and assign variables
Declare and assign a variable for each item in the list above.
Hint: When declaring and assigning your variables, remember that you will need to use that variable throughout the rest of the exercises. Make sure that you are using the correct data type!
Calculate a space mission!
We need to determine how many days it will take to reach Mars.
Print out the results of your calculations
Using variables from above, print to the screen a sentence that
says "_____ will take ___ days to reach Mars."
Fill in the blanks with
the shuttle name and the calculated time.
Click “Run” (in repl.it) and verify that your code works before moving on.
Now calculate a trip to the Moon
Repeat the calculations, but this time determine the number of days it would
take to travel to the Moon and print to the screen a sentence that says
"_____ will take ___ days to reach the Moon."
.