pxt-calliope/olddocs/lessons/prank-wifi/quiz-answers.md

108 lines
2.5 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# prank wifi quiz answers
2016-04-02 01:22:47 +02:00
create a fake wifi app to trick your friends.
2016-03-26 00:47:20 +01:00
## Name
## Directions
2016-04-16 00:02:26 +02:00
Use this activity document to guide your work in the [prank WiFi activity](/lessons/prank-wifi/activity)
2016-03-26 00:47:20 +01:00
Answer the questions while completing the tutorial. Pay attention to the dialogues!
## 1. Write the lines of code that takes the absolute value of the accelerations with respect to the x, y and z axis and stores the values as Local Variables
<br/>
2016-03-31 02:15:42 +02:00
```blocks
2016-04-01 02:01:28 +02:00
let xAccel = Math.abs(input.acceleration(Dimension.X))
let yAccel = Math.abs(input.acceleration(Dimension.Y))
let zAccel = Math.abs(input.acceleration(Dimension.Z))
2016-03-26 00:47:20 +01:00
```
<br/>
## 2. Write the lines of code that add all the accelerations together to get the total acceleration and stores the value as a Local Variable called "sum"
<br/>
<br/>
2016-03-31 02:15:42 +02:00
```blocks
2016-04-01 02:01:28 +02:00
let xAccel = Math.abs(input.acceleration(Dimension.X))
let yAccel = Math.abs(input.acceleration(Dimension.Y))
let zAccel = Math.abs(input.acceleration(Dimension.Z))
2016-03-26 00:47:20 +01:00
let sum = xAccel + yAccel + zAccel
```
<br/>
## 3. Write the 'If statement' used if the sum of the acceleration value is less than 1400 milli-gravitys. Then write the code that will plot an image of the fake amount of WiFi if the acceleration in this 'If statement'
<br/>
2016-03-31 02:15:42 +02:00
```blocks
2016-04-01 02:01:28 +02:00
let xAccel = Math.abs(input.acceleration(Dimension.X))
let yAccel = Math.abs(input.acceleration(Dimension.Y))
let zAccel = Math.abs(input.acceleration(Dimension.Z))
let sum = xAccel + yAccel + zAccel
2016-03-26 00:47:20 +01:00
if (sum < 1400) {
2016-04-01 02:17:22 +02:00
basic.showLeds(`
2016-03-26 00:47:20 +01:00
. . . . .
. . . . .
. . # . .
. # # . .
# # # . .
`)
}
```
<br/>
## 4. Write tje 'If statement' used if the sum of the acceleration value is greater than 1400 milli-gravitys but less than 1680 milli-gravitys. Then write the code that will plot an image of the fake amount of WiFi inside this 'If statement'
<br/>
<br/>
2016-03-31 02:15:42 +02:00
```blocks
2016-04-01 02:01:28 +02:00
let xAccel = Math.abs(input.acceleration(Dimension.X))
let yAccel = Math.abs(input.acceleration(Dimension.Y))
let zAccel = Math.abs(input.acceleration(Dimension.Z))
let sum = xAccel + yAccel + zAccel
2016-03-26 00:47:20 +01:00
if (sum >= 1400 && sum < 1680) {
2016-04-01 02:17:22 +02:00
basic.showLeds(`
2016-03-26 00:47:20 +01:00
. . . . .
. . . # .
. . # # .
. # # # .
# # # # .
`)
}
```
2016-04-01 02:01:28 +02:00
## 5. Write the code to display this specific image on the device
2016-03-26 00:47:20 +01:00
![](/static/mb/lessons/prank-wifi-0.png)
<br/>
<br/>
2016-04-01 02:01:28 +02:00
```blocks
let xAccel = Math.abs(input.acceleration(Dimension.X))
let yAccel = Math.abs(input.acceleration(Dimension.Y))
let zAccel = Math.abs(input.acceleration(Dimension.Z))
let sum = xAccel + yAccel + zAccel
2016-03-26 00:47:20 +01:00
if (sum >= 1680) {
2016-04-01 02:17:22 +02:00
basic.showLeds(`
2016-03-26 00:47:20 +01:00
. . . . .
. . . . .
. . . . .
. . . . .
# . . . .
`)
}
```