In this lesson, you will learn the following:
Here are a few tips to help you with this learning activity:
Let's get started!
Jean and her friends were somehow transported into their school's computer lab!
Avoid the evil Megabytes and collect the memory chips—help Motherboard regain her lost memory. Can you help Jean restore the balance and return to reality?
Jump obstacles!
Blast baddies!
Oh, and just one more thing: Stay on the path!
In the previous lesson, you learned that functions can be called, and they will execute one-at-a-time.
Sequencing describes the order of events or code instructions. In short, when a program runs, each individual instruction in the program will be executed, one after the other. This is called its sequence.
Hint: You’ll often have to rearrange code instructions and experiment with the sequence of your code.
In this challenge sequence, you'll take control of the player character shown below. Your goal is to reach the card at the end of the path — that's a memory chip!
You can move the characters around on the game grid using code! This first puzzle has already been solved for you. Notice how the code appears at the bottom. In the next puzzle, you'll need to write Python code yourself.
Press run to watch the solution play. Click Next to continue.
Use the forward()
function to reach the memory chip.
Command | Description |
---|---|
forward() |
Moves the character one step forward. |
When you're using programming languages like Python, the details really matter. If you misspell one word, or if you forget even a little bit of punctuation, your code won't run!
If you get an error, check your code closely for errors.
To move the character one step forward, you need to type the forward()
command in the coding area.
forward()
function twice. Don't forget the parentheses!Use the forward()
command to reach the memory chips.
Command | Description |
---|---|
forward() |
Moves the character one step forward. |
You'll need to use the forward()
function three times, putting each command on a new line.
When you're using programming languages like Python, the details really matter. If you misspell one word, or if you forget even a little bit of punctuation, your code won't run!
If you get an error, read your code closely for errors. Make sure you don't forget the parentheses.
Navigate the corner using the turn_right()
command and get that memory chip!
Command | Description |
---|---|
forward() |
Moves the character one step forward. |
turn_right() |
Turns the character to the right. |
turn_right()
command will turn the character to the right.Reach the memory chip. Just be sure to stun those Megabyte Chompers!
Command | Description |
---|---|
forward() |
Moves the character one step forward. |
stun() |
Launches an stun bolt that travels 5 blocks in the direction the character is facing. |
stun()
command to get rid of them.