pxt-calliope/docs/lessons/compass/quiz-answers.md

55 lines
1.2 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# compass quiz answers
Create an actual compass to show your direction: North, South, East, or West
## Name
## Directions
2016-04-13 17:27:45 +02:00
Use this activity document to guide your work in the [compass tutorial](/lessons/compass/activity).
2016-03-26 00:47:20 +01:00
Answer the questions while completing the tutorial. Pay attention to the dialogues!
## 1. What is the purpose of the 'compass heading' block?
2016-11-02 01:44:37 +01:00
Gets the compass heading of the @boardname@ in degrees
2016-03-26 00:47:20 +01:00
## 2. Write the code that stores the compass heading into a local variable called 'degrees'.
2016-03-30 01:17:34 +02:00
```blocks
2016-03-26 00:47:20 +01:00
let degrees = input.compassHeading()
```
2016-11-02 01:44:37 +01:00
## 3. Write the 'If statement' that will check if the device is mostly pointing North. Display 'N' on the @boardname@
2016-03-26 00:47:20 +01:00
2016-03-30 01:17:34 +02:00
```blocks
2016-03-31 00:11:05 +02:00
let degrees = input.compassHeading()
2016-03-26 00:47:20 +01:00
if (degrees < 45) {
basic.showString("N", 150)
}
```
2016-11-02 01:44:37 +01:00
## 4. Write the 'If statement' that will check if the device is mostly pointing East. Display 'E' on the @boardname@
2016-03-26 00:47:20 +01:00
2016-03-30 01:17:34 +02:00
```blocks
2016-03-31 00:11:05 +02:00
let degrees = input.compassHeading()
2016-03-26 00:47:20 +01:00
if (degrees < 135) {
basic.showString("E", 150)
}
```
2016-11-02 01:44:37 +01:00
## 5. Write the 'If statement' that will check if the device is mostly pointing South. Display 'S' on the @boardname@
2016-03-26 00:47:20 +01:00
2016-03-30 01:17:34 +02:00
```blocks
2016-03-31 00:11:05 +02:00
let degrees = input.compassHeading()
2016-03-26 00:47:20 +01:00
if (degrees < 225) {
basic.showString("S", 150)
}
```