ROUND, RANDOM and a trace · ROUND, RANDOM et une trace
A shop rounds a price
ROUND(Value, Places)returnsValuerounded toPlacesdecimal places.Placesis an integer.ROUND(3.14159, 2)is3.14.ROUND(9.6, 0)is the whole number10.- The syllabus lists
ROUNDwithDIV,MODandRANDOM.
Un magasin arrondit un prix
ROUND(Value, Places)retourneValuearrondi àPlacesdécimales.Placesest un entier.ROUND(3.14159, 2)est3.14.ROUND(9.6, 0)est le nombre entier10.- Le programme officiel liste
ROUNDavecDIV,MODetRANDOM.
OUTPUT ROUND(3.14159, 2)
OUTPUT ROUND(9.6, 0)
A dice uses RANDOM
RANDOM()returns a real from 0 to 1, including both ends. Each run can differ.- A board-game dice is
ROUND(RANDOM() * 6, 0). The paper uses it when the result may vary, so you are not asked for one fixed output.
Un dé utilise RANDOM
RANDOM()retourne un réel entre 0 et 1, incluant les deux extrémités. Chaque exécution peut différer.- Un dé de jeu de société est
ROUND(RANDOM() * 6, 0). Le papier l'utilise lorsque le résultat peut varier, donc vous n'êtes pas demandé un seul résultat fixe.
OUTPUT ROUND(RANDOM() * 6, 0)
Fill a trace table
- A trace table is a dry run. One row is one pass of the loop. You write the variables after that pass.
Totalstarts at 0. AfterI = 1it is 1. AfterI = 2it is 3. AfterI = 3it is 6.
| I | Total |
|---|---|
| 1 | 1 |
| 2 | 3 |
| 3 | 6 |
Remplir une table de traçage
- Une table de traçage est un essai sec. Une ligne correspond à une passe de boucle. Vous écrivez les variables après cette passe.
Totalcommence à 0. AprèsI = 1, c'est 1. AprèsI = 2, c'est 3. AprèsI = 3, c'est 6.
| I | Total |
|---|---|
| 1 | 1 |
| 2 | 3 |
| 3 | 6 |
One row per pass · Une ligne par passage
A trace table records each variable after that pass of the loop. Here Total is the running sum of I. · Un tableau de trace enregistre chaque variable après ce passage de boucle. Ici Total est la somme courante de I.
DECLARE I, Total : INTEGER
Total ← 0
FOR I ← 1 TO 3
Total ← Total + I
OUTPUT I, " ", Total
NEXT I
Watch out
- Round a half only when you have checked the digit. The tasks here are not on a halfway value.
RANDOM()is notRAND.RANDbelongs to the 9618 guide, not to this syllabus.
Attention
- Arrondissez un demi uniquement lorsque vous avez vérifié le chiffre. Les tâches ici ne concernent pas une valeur intermédiaire.
RANDOM()n'est pasRAND.RANDappartient au guide 9618, pas à ce programme officiel.
Common mistakes
ROUNDtakes the value first and the number of places second.- In a trace, record the values after the line has run, not the values you hope the next line will produce.
Erreurs courantes
ROUNDprend la valeur d'abord et le nombre de places ensuite.- Dans un traçage, enregistrez les valeurs après l'exécution de la ligne, pas les valeurs dont vous espériez que la prochaine ligne produirait.
Now you try
- The first task is
ROUND. The second prints a trace, one row per line. - Press Check answer to test it.
À vous maintenant
- La première tâche est
ROUND. La seconde affiche un traçage, une ligne par ligne. - Appuyez sur Vérifier la réponse pour tester.
Output · Sortie ROUND(3.14159, 2) and · et ROUND(9.6, 0), each on its own line. · Affichez ROUND(3.14159, 2) et ROUND(9.6, 0), chacun sur sa propre ligne.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.
Start · Commencer Total at 0. For I from 1 to · à 3, add I to · à Total and output I, a space, and Total on that line. The three lines are the trace. · Commencer Total à 0. Pour I de 1 à 3, ajouter I à Total et afficher I, un espace, et Total sur cette ligne. Les trois lignes constituent la trace.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.