How Old Are You on Mars?
Background
Digital technologies have changed how people learn, work and live. Digital literacy is a critical skill and continues to become increasingly important for the future. Deep-space missions are relying more and more on artificial intelligence (AI) and programming to create autonomous robots that can make decisions on their own. Canada is building Canadarm3 for the Lunar Gateway, a small space station that will orbit the Moon. Canadarm3 will require programming that was not necessary in the previous Canadarms in order to complete tasks on a daily basis almost 400,000 km from Earth. Future missions to Mars will require even more autonomy and sophisticated programming. Coding is one way to use imagination and innovation to create something new. This introductory coding activity shows participants just how easy it can be to start on the path to becoming digitally savvy.
Mission description
As you probably know, a year is the period of time that Earth takes to complete an orbit around the Sun. Our nearest planetary neighbour, Mars, has a larger orbit around the Sun than Earth does. This difference in orbits is why a Martian year is much longer than an Earth year. In fact, in Martian years you're about half as old as you are in Earth years!
Scientists and engineers (among others) often use computers to process data or perform complicated or repetitive calculations for them. To do this, they are sometimes required to write code to describe the calculation they would like performed. In this challenge, you will create a small program that takes your age in Earth years and outputs your age in Martian years. You will use JavaScript, a programming language used everywhere online. It's accessible if you have a Web browser and easy to understand.
You will start by doing the calculation by hand, so that you understand the math behind the conversion, and to give you an appreciation of the benefits of coding.
Timeline
Breakdown | Duration |
---|---|
Background | 5 minutes |
Instructions | 15 minutes |
Group activity | 25 minutes |
Wrap-up | 5 minutes |
Total | 50 minutes |
Goal
Participants will learn about simple coding.
Objective
By the end of this mission, participants will:
- Understand the difference in planetary cycles
- Understand how to do a simple code using JavaScript
- Understand how this type of coding can simplify large amounts of work
Mission preparation
Materials
- Paper and pencil
- Calculator
- Computer with a Web browser (e.g. Google Chrome, Microsoft Edge, Mozilla Firefox)
Terminology
-
Statement: most of what you will code in JavaScript will be made of statements. Below, you will see many semicolons (;). These denote the end of a statement. In most programming languages, semicolons are required, but they are optional in JavaScript. Still, it's good practice to use them.
-
Variable: a variable stores a piece of information, called a value. In JavaScript, variables are created using the var keyword. To assign a value to a variable, use the following syntax:
var country = 'canada';
- The variable country now holds the value canada.
- In the following exercise, earthAgeYears, earthAgeDays, marsAgeDays and marsAgeYears are all variables that store numbers.
- Because variable names cannot have spaces, we separate different words by makingEachOneStartWithACapitalLetter. Note that variables conventionally start with a lowercase letter.
-
Mathematical operations: are represented similarly to how they are written by hand. "Plus" is , "minus" is , "multiply" is , and "divide" is .
-
Console: an interface for real-time programming. The console we use lives in your Web browser. After you type in some code, hit the Enter key and your code will immediately be run. Its results will also be displayed.