Skip to content

Commit

Permalink
a few format fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ganicke committed Oct 1, 2024
1 parent 79a756e commit 5c8c1c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/courses/csintro/conditionals/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ input.onGesture(Gesture.Shake, () => {
```
Solution link: [https://makecode.microbit.org/_0fx9hY9EbM5T]()

### ~ Bonus
### Bonus

The micro:bit uses its accelerometer to detect when you're shaking it. How does an accelerometer actually work?

Expand Down
14 changes: 9 additions & 5 deletions docs/courses/csintro/variables/activity.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ In MakeCode, from the Variables menu, make and name these three variables: `Play

![Set new variable name](/static/courses/csintro/variables/new-variable.png)

## Initializing the variable value
## Initializing the variable value

It is important to give your variables an initial value. The initial value is the value the variable will hold each time the program starts. For our counter program, we will give each variable the value 0 (zero) at the start of the program.

```blocks
Expand Down Expand Up @@ -70,7 +71,9 @@ input.onButtonPressed(Button.AB, () => {
PlayersTie += 1
})
```

## User feedback

Whenever the scorekeeper presses button A, button B, or both buttons together, we will give the user visual feedback acknowledging that the user pressed a button. We can do this by coding our program to display:

* an ‘A’ each time the user presses button A to record a win for Player A,
Expand Down Expand Up @@ -199,7 +202,7 @@ PlayerBWins = 0
PlayersTie = 0
```

### ~ Hint
### ~ hint

Buttons have been used as human input devices since computers first existed. Watch this video and see how they let the user tell the micro:bit to do something.

Expand All @@ -208,9 +211,11 @@ Buttons have been used as human input devices since computers first existed. Wat
### ~

## Try it out!

Download the Scorekeeper program to the micro:bit, and find someone to play *Rock, Paper, Scissors* with you using your micro:bit to act as the Scorekeeper!

## ‘Adding’ on with mathematical operations
## 'Adding' on with mathematical operations

There is more we can do with the input we received using this program. We can use mathematical operations on our variables.

Example: Perhaps you’d like to keep track of, and show the player the total number of ‘rounds’ that were played. To do this, we can add the values stored in the variables we created to keep track of how many times each player won and how many times they tied.
Expand All @@ -227,6 +232,7 @@ In order to do this, we can add the code to our program under the 'on shake' eve
![Operator selector](/static/courses/csintro/variables/operator-selector.png)

* Replace the default values of zero with the names of the variables we want to add together.

Notice that because we are adding three variables together we need a second math block. First we add the values for `PlayerAWins` and `PlayerBWins`, then add `PlayersTie`.

```blocks
Expand Down Expand Up @@ -255,9 +261,7 @@ Examples:
Questions:

1. What's the difference between a constant and a variable?

2. Why is it important to name variables in a clear and meaningful way?

3. **True or false:** You can only use the default variable names provided in the Variables toolbox drawer.

Answers:
Expand Down

0 comments on commit 5c8c1c8

Please sign in to comment.