Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added cy-GB/images/changing-operator.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cy-GB/images/comparison-blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cy-GB/images/elseif-blocks.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cy-GB/images/if-block-location.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions cy-GB/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Selection
hero_image: images/banner.png
description: How to use if blocks for selection on the micro:bit
version: 4
listed: false
copyedit: false
last_tested: "2022-05-19"
steps:
-
title: Using if blocks for selection on the micro:bit
7 changes: 7 additions & 0 deletions cy-GB/microbit-translatable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The Logic menu with the `if` block highlighted.

The Comparison section of the Logic menu, with three blocks showing: 0 = 0, 0 > 0, and a string comparison block.

A demonstration of using the drop-down menu on a comparison block to change the operator.

An animation showing the + symbol being used to add three 'else if' sections. Finally, the 'else' is removed from the end by clicking the '-' symbol next to it.
77 changes: 77 additions & 0 deletions cy-GB/step_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
There might be times when you want a specific part of your program to run **only** when a certain condition is met. In programming, this is called **selection**.

In MakeCode, the most important block you will use for selection is the `if`{:class='microbitlogic'} block.

### Using an if block

You will find the `if`{:class='microbitlogic'} block in the `Logic`{:class='microbitlogic'} menu.

<img src="images/if-block-location.png" alt="The Logic menu with the `if` block highlighted." width="350"/>

You have to put `if`{:class='microbitlogic'} blocks inside other blocks, like `forever`{:class='microbitbasic'} loops or an `on button pressed`{:class='microbitinput'} block.

You can place other blocks **inside** an `if`{:class='microbitlogic'} block, and they will only run **if** the condition is `true`.

### The condition

An important part of the `if`{:class='microbitlogic'} block is the **condition**. The blocks inside an `if`{:class='microbitlogic'} will only run if a condition is `true`.

You can find the condition blocks in the `Logic`{:class='microbitlogic'} menu of the Toolbox.

<img src="images/comparison-blocks.png" alt="The Comparison section of the Logic menu, with three blocks showing: 0 = 0, 0 >

A condition has two parts:

1. Data
2. An operator

**Data**

There has to be data on either side of your condition. This can be a variable, a sensor reading, a `true/false`, or a number.

**Operator**

The operators is **how** you are comparing the two pieces of data.

You can think of the operator like a question you are asking about your two pieces of data.

The operators you can use are:

- `=` — are the two sides **equal**?
- `≠` — are the two sides **not equal**?
- `>` — is the first piece of data **greater than** the second?
- `<` — is the first piece of data **less than** the second?
- `≥` — is the first piece of data **greater than or equal to** the second?
- `≤` — is the first piece of data **less than or equal to** the second?

You can choose an operator by dragging a comparison block into your `if`{:class='microbitlogic'} block and clicking on the drop-down menu.

<img src="images/changing-operator.gif" alt="A demonstration of using the drop-down menu on a comparison block to change the operator." width="300"/>

#### else if and else

You can also add more possible outcomes to your `if`{:class='microbitlogic'} block with `else`{:class='microbitlogic'} and `else if`{:class='microbitlogic'} blocks.

**else**

Sometimes you might want some code to run if the condition in your `if`{:class='microbitlogic'} block is `false`. To do this, you can use an `else`{:class='microbitlogic'}.

The blocks inside the `else`{:class='microbitlogic'} part will run **only** when the condition is `false`.

To add an `else`{:class='microbitlogic'}, you need to click the `+` symbol at the bottom of your `if`{:class='microbitlogic'} block.

There is also an `if else`{:class='microbitlogic'} block that you can use if you know you will need to do one thing if a condition is true and another if a condition is false.

**else if**

An `else if`{:class='microbitlogic'} block allows you to add another condition to check.

**It will only check the second condition if the first condition is `false`. If you always want both conditions to be checked, you have to add a second `if`{:class='microbitlogic'} block.**

To add an `else if`{:class='microbitlogic'} block, you click the `+` symbol at the bottom of the `if`{:class='microbitlogic'} block.

<img src="images/elseif-blocks.gif" alt="An animation showing the + symbol being used to add three 'else if' sections. Finally, the 'else' is removed from the end by clicking the '-' symbol next to it." width="350"/>

If you just want an `else if`{:class='microbitlogic'}, you will have to click the `+` twice and then `-` the `else`{:class='microbitlogic'}.

You will then have to add another `condition`.
Binary file modified el-GR/images/changing-operator.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified el-GR/images/comparison-blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified el-GR/images/elseif-blocks.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified el-GR/images/if-block-location.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions el-GR/meta.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
title: Selection
title: Επιλογή
hero_image: images/banner.png
description: How to use if blocks for selection on the micro:bit
description: Πώς να χρησιμοποιήσεις τα μπλοκ εάν για επιλογή στο micro:bit
version: 4
listed: false
copyedit: false
last_tested: "2022-05-19"
steps:
- title: Using if blocks for selection on the micro:bit
-
title: Χρήση μπλοκ εάν για επιλογή στο micro:bit
7 changes: 7 additions & 0 deletions el-GR/microbit-translatable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Το μενού Λογική με τονισμένο το μπλοκ `εάν`.

Η ενότητα Σύγκριση του μενού Λογική, με τρία μπλοκ που εμφανίζουν: 0 = 0, 0 > 0 και ένα μπλοκ σύγκρισης συμβολοσειρών.

Μια επίδειξη χρήσης του αναπτυσσόμενου μενού σε ένα μπλοκ σύγκρισης για την αλλαγή του τελεστή.

Μια κινούμενη εικόνα που δείχνει το σύμβολο + που χρησιμοποιείς για να προσθέσεις τρεις ενότητες 'αλλιώς εάν'. Στο τέλος, το 'αλλιώς' αφαιρείται από το τέλος κάνοντας κλικ στο σύμβολο '-' δίπλα του.
80 changes: 41 additions & 39 deletions el-GR/step_1.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,77 @@
There might be times when you want a specific part of your program to run **only** when a certain condition is met. In programming, this is called **selection**.
Μπορεί να υπάρχουν φορές που θέλεις ένα συγκεκριμένο μέρος του προγράμματός σου να εκτελείται **μόνο** όταν εκπληρωθεί μια συγκεκριμένη συνθήκη. Στον προγραμματισμό, αυτό ονομάζεται **επιλογή**.

In MakeCode, the most important block you will use for selection is the `if`{:class='microbitlogic'} block.
Στο MakeCode, το πιο σημαντικό μπλοκ που θα χρησιμοποιήσεις για επιλογή είναι το μπλοκ `εάν`{:class='microbitlogic'}.

### Using an if block
### Χρησιμοποιώντας ένα μπλοκ εάν

You will find the `if`{:class='microbitlogic'} block in the `Logic`{:class='microbitlogic'} menu.
Θα βρεις το μπλοκ `εάν`{:class='microbitlogic'} στο μενού `Λογική`{:class='microbitlogic'}.

<img src="images/if-block-location.png" alt="The Logic menu with the `if` block highlighted." width="350"/>

You have to put `if`{:class='microbitlogic'} blocks inside other blocks, like `forever`{:class='microbitbasic'} loops or an `on button pressed`{:class='microbitinput'} block.
Πρέπει να τοποθετήσεις τα μπλοκ `εάν`{:class='microbitlogic'} μέσα σε άλλα μπλοκ, όπως βρόχους `για πάντα`{:class='microbitbasic'} ή ένα μπλοκ `όταν πιεστεί το πλήκτρο`{:class='microbitinput'}.

You can place other blocks **inside** an `if`{:class='microbitlogic'} block, and they will only run **if** the condition is `true`.
Μπορείτε να τοποθετήσετε άλλα μπλοκ **μέσα** σε ένα μπλοκ `if`{:class='microbitlogic'} και αυτά θα εκτελεστούν μόνο **εάν** η συνθήκη είναι `αληθής`.

### The condition
### Η συνθήκη

An important part of the `if`{:class='microbitlogic'} block is the **condition**. The blocks inside an `if`{:class='microbitlogic'} will only run if a condition is `true`.
Ένα σημαντικό μέρος του μπλοκ `εάν`{:class='microbitlogic'} είναι η **συνθήκη**. Τα μπλοκ μέσα σε ένα `εάν`{:class='microbitlogic'} θα εκτελούνται μόνο εάν μια συνθήκη είναι `αληθής`.

You can find the condition blocks in the `Logic`{:class='microbitlogic'} menu of the Toolbox.
Μπορείς να βρεις τα μπλοκ συνθήκης στο μενού `Λογική`{:class='microbitlogic'} της Εργαλειοθήκης.

<img src="images/comparison-blocks.png" alt="The Comparison section of the Logic menu, with three blocks showing: 0 = 0, 0 > 0, and a string comparison block." width="300"/>
<img src="images/comparison-blocks.png" alt="The Comparison section of the Logic menu, with three blocks showing: 0 = 0, 0 >

A condition has two parts:
1. Data
2. An operator
Μια συνθήκη έχει δύο μέρη:

**Data**
1. Δεδομένα
2. Έναν τελεστή

There has to be data on either side of your condition. This can be a variable, a sensor reading, a `true/false`, or a number.
**Δεδομένα**

**Operator**
Πρέπει να υπάρχουν δεδομένα και από τις δύο πλευρές της συνθήκης σου. Αυτό μπορεί να είναι μια μεταβλητή, μια ένδειξη αισθητήρα, ένα `αληθές/ψευδές` ή ένας αριθμός.

The operators is **how** you are comparing the two pieces of data.
**Τελεστής**

You can think of the operator like a question you are asking about your two pieces of data.
Οι τελεστές είναι **πώς** συγκρίνεις τα δύο τμήματα των δεδομένων.

The operators you can use are:
+ `=` — are the two sides **equal**?
+ `≠` — are the two sides **not equal**?
+ `>` — is the first piece of data **greater than** the second?
+ `<` — is the first piece of data **less than** the second?
+ `≥` — is the first piece of data **greater than or equal to** the second?
+ `≤` — is the first piece of data **less than or equal to** the second?
Μπορείς να σκεφτείς τον τελεστή σαν μια ερώτηση που ρωτάς για τα δύο τμηματα των δεδομένα σου (τελεστέοι).

You can choose an operator by dragging a comparison block into your `if`{:class='microbitlogic'} block and clicking on the drop-down menu.
Οι τελεστές που μπορείς να χρησιμοποιήσεις είναι:

- `=` — είναι οι δύο τελεστέοι**ίσοι**;
- `≠` — οι δύο τελεστέοι **δεν είναι ίσοι**;
- `>` — είναι το πρώτο τμήμα δεδομένων **μεγαλύτερο από** το δεύτερο;
- `<` — είναι το πρώτο τμήμα δεδομένων **μικρότερο από** το δεύτερο;
- `≥` — είναι το πρώτο τμήμα δεδομένων **μεγαλύτερο ή ίσο** με το δεύτερο;
- `≤` — είναι το πρώτο τμήμα δεδομένων **μικρότερο ή ίσο** με το δεύτερο;

Μπορείς να επιλέξεις έναν τελεστή σύροντας ένα μπλοκ σύγκρισης στο μπλοκ `εάν`{:class='microbitlogic'} και κάνοντας κλικ στο αναπτυσσόμενο μενού.

<img src="images/changing-operator.gif" alt="A demonstration of using the drop-down menu on a comparison block to change the operator." width="300"/>

#### else if and else
#### αλλιώς εάν και αλλιώς

You can also add more possible outcomes to your `if`{:class='microbitlogic'} block with `else`{:class='microbitlogic'} and `else if`{:class='microbitlogic'} blocks.
Μπορείς επίσης να προσθέσεις περισσότερα πιθανά αποτελέσματα στο μπλοκ `εάν`{:class='microbitlogic'} με τα μπλοκ `αλλιώς`{:class='microbitlogic'} και `αλλιώς εάν`{:class='microbitlogic'}.

**else**
**αλλιώς**

Sometimes you might want some code to run if the condition in your `if`{:class='microbitlogic'} block is `false`. To do this, you can use an `else`{:class='microbitlogic'}.
Μερικές φορές μπορεί να χρειαστεί να εκτελεστεί κάποιος κώδικας εάν η συνθήκη στο μπλοκ `εάν`{:class='microbitlogic'} είναι `ψευδής`. Για να το κάνεις αυτό, μπορείς να χρησιμοποιήσεις μια συνάρτηση `αλλιώς`{:class='microbitlogic'}.

The blocks inside the `else`{:class='microbitlogic'} part will run **only** when the condition is `false`.
Τα μπλοκ μέσα σε ένα `εάν`{:class='microbitlogic'} θα εκτελούνται μόνο εάν μια συνθήκη είναι `αληθής`.

To add an `else`{:class='microbitlogic'}, you need to click the `+` symbol at the bottom of your `if`{:class='microbitlogic'} block.
Για να προσθέσεις ένα `αλλιώς`{:class='microbitlogic'}, πρέπει να κάνεις κλικ στο σύμβολο `+` στο κάτω μέρος του μπλοκ `εάν`{:class='microbitlogic'}.

There is also an `if else`{:class='microbitlogic'} block that you can use if you know you will need to do one thing if a condition is true and another if a condition is false.
Υπάρχει επίσης ένα μπλοκ `if else`{:class='microbitlogic'} που μπορείς να χρησιμοποιήσεις αν γνωρίζεις ότι θα χρειαστεί να κάνεις ένα πράγμα αν μια συνθήκη είναι αληθής και ένα άλλο αν μια συνθήκη είναι ψευδής.

**else if**
**αλλιώς εάν**

An `else if`{:class='microbitlogic'} block allows you to add another condition to check.
Ένα μπλοκ `αλλιώς εάν`{:class='microbitlogic'} σου επιτρέπει να προσθέσεις μια άλλη συνθήκη για έλεγχο.

**It will only check the second condition if the first condition is `false`. If you always want both conditions to be checked, you have to add a second `if`{:class='microbitlogic'} block.**
Θα ελέγξει τη δεύτερη συνθήκη μόνο εάν η πρώτη συνθήκη είναι `ψευδής`. Αν θέλεις να ελέγχονται πάντα και οι δύο συνθήκες, πρέπει να προσθέσεις ένα δεύτερο μπλοκ `εάν`{:class='microbitlogic'}.\*\*

To add an `else if`{:class='microbitlogic'} block, you click the `+` symbol at the bottom of the `if`{:class='microbitlogic'} block.
Για να προσθέσεις ένα μπλοκ `αλλιώς εάν`{:class='microbitlogic'}, πρέπει να κάνεις κλικ στο σύμβολο `+` στο κάτω μέρος του μπλοκ `εάν`{:class='microbitlogic'}.

<img src="images/elseif-blocks.gif" alt="An animation showing the + symbol being used to add three 'else if' sections. Finally, the 'else' is removed from the end by clicking the '-' symbol next to it." width="350"/>

If you just want an `else if`{:class='microbitlogic'}, you will have to click the `+` twice and then `-` the `else`{:class='microbitlogic'}.
Αν θέλεις απλώς ένα `αλλιώς εάν`{:class='microbitlogic'}, θα πρέπει να κάνεις κλικ στο `+` δύο φορές και στη συνέχεια στο `-` στο `αλλιώς`{:class='microbitlogic'}.

You will then have to add another `condition`.
Στη συνέχεια, θα πρέπει να προσθέσεις μια άλλη `συνθήκη`.
4 changes: 2 additions & 2 deletions fr-FR/meta.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
title: Sélection
hero_image: images/banner.png
description: Comment utiliser les blocs si pour la sélection sur le micro:bit
Expand All @@ -7,4 +6,5 @@ listed: false
copyedit: false
last_tested: "2022-05-19"
steps:
- title: Utilise des blocs si pour la sélection sur le micro:bit
-
title: Utilise des blocs si pour la sélection sur le micro:bit
7 changes: 7 additions & 0 deletions fr-FR/microbit-translatable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The Logic menu with the `if` block highlighted.

The Comparison section of the Logic menu, with three blocks showing: 0 = 0, 0 > 0, and a string comparison block.

A demonstration of using the drop-down menu on a comparison block to change the operator.

An animation showing the + symbol being used to add three 'else if' sections. Finally, the 'else' is removed from the end by clicking the '-' symbol next to it.
8 changes: 4 additions & 4 deletions fr-FR/step_1.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Une partie importante du bloc `si`{:class='microbitlogic'} est la **condition**.

Tu peux trouver les blocs de conditions dans le menu `Logique`{:class='microbitlogic'} de la boîte à outils.

<img src="images/comparison-blocks.png" alt="The Comparison section of the Logic menu, with three blocks showing: 0 = 0, 0 > 0, and a string comparison block." width="300"/>
<img src="images/comparison-blocks.png" alt="The Comparison section of the Logic menu, with three blocks showing: 0 = 0, 0 >

Une condition comporte deux parties :

Expand All @@ -27,7 +27,7 @@ Une condition comporte deux parties :

**Données**

Il doit y avoir des données de chaque côté de ta condition. Cela peut être une variable, une lecture de capteur, un `vrai/faux` ou un nombre.
Il doit y avoir des données de chaque côté de ta condition. Cela peut être une variable, une lecture de capteur, un ` vrai/faux` ou un nombre.

**Opérateur**

Expand All @@ -42,7 +42,7 @@ Les opérateurs que tu peux utiliser sont :
- `>` — la première donnée est-elle **supérieure** à la deuxième ?
- `<` — la première donnée est-elle **inférieure** à la deuxième ?
- `≥` — la première donnée est-elle **supérieure ou égale** à la deuxième ?
- `≤` — la première donnée est-elle **inférieure ou égale** à la deuxième ?
- « ≤ » — la première donnée est-elle **inférieure ou égale** à la deuxième ?

Tu peux choisir un opérateur en faisant glisser un bloc de comparaison dans ton bloc `si`{:class='microbitlogic'} et en cliquant sur le menu déroulant.

Expand All @@ -56,7 +56,7 @@ Tu peux également ajouter plus de résultats possibles à ton bloc `si`{:class=

Parfois, tu souhaites peut-être que du code s'exécute si la condition dans ton bloc `si`{:class='microbitlogic'} est `faux`. Pour cela, tu peux utiliser un `sinon`{:class='microbitlogic'}.

Les blocs à l'intérieur de la partie `sinon`{:class='microbitlogic'} s'exécuteront **seulement** lorsque la condition est `fausse`.
Les blocs à l'intérieur de la partie sinon`{:class='microbitlogic'} s'exécuteront **seulement** lorsque la condition est `fausse\`.

Pour ajouter un `sinon`{:class='microbitlogic'}, tu dois cliquer sur le symbole `+` en bas de ton bloc `si`{:class='microbitlogic'}.

Expand Down
4 changes: 2 additions & 2 deletions nl-NL/meta.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
title: Selectie
hero_image: images/banner.png
description: Hoe gebruik je als blokken voor selectie op de micro:bit
Expand All @@ -7,4 +6,5 @@ listed: false
copyedit: false
last_tested: "2022-05-19"
steps:
- title: Als blokken gebruiken voor selectie op de micro:bit
-
title: Als blokken gebruiken voor selectie op de micro:bit
7 changes: 7 additions & 0 deletions nl-NL/microbit-translatable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The Logic menu with the `if` block highlighted.

The Comparison section of the Logic menu, with three blocks showing: 0 = 0, 0 > 0, and a string comparison block.

A demonstration of using the drop-down menu on a comparison block to change the operator.

An animation showing the + symbol being used to add three 'else if' sections. Finally, the 'else' is removed from the end by clicking the '-' symbol next to it.
Loading