ROUND, RANDOM and a trace · ROUND, RANDOM y una traza
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.
Una tienda redondea un precio
ROUND(Value, Places)devuelve elValueredondeado aPlacesdecimales.Placeses un entero.ROUND(3.14159, 2)da como resultado3.14.ROUND(9.6, 0)da como resultado el número entero10.- El programa de estudios lista
ROUNDjunto conDIV,MODyRANDOM.
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 dado usa RANDOM
RANDOM()devuelve un número real entre 0 y 1, incluyendo ambos extremos. Cada ejecución puede dar un resultado diferente.- Un dado de juego de mesa se representa mediante
ROUND(RANDOM() * 6, 0). El documento lo utiliza cuando el resultado puede variar, por lo que no se pide una salida fija única.
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 |
Rellenar una tabla de trazado
- Una tabla de trazado es una simulación manual. Una fila corresponde a cada iteración del bucle. Se escriben las variables después de dicha iteración.
Totalcomienza en 0. Después deI = 1, su valor es 1. Después deI = 2, su valor es 3. Después deI = 3, su valor es 6.
| I | Total |
|---|---|
| 1 | 1 |
| 2 | 3 |
| 3 | 6 |
One row per pass · Una fila por pasada
A trace table records each variable after that pass of the loop. Here Total is the running sum of I. · Una tabla de trazas registra cada variable después de esa pasada del bucle. Aquí Total es la suma acumulativa 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.
Ten cuidado
- Redondee solo la mitad cuando haya verificado el dígito correspondiente. Las tareas aquí no tratan sobre valores intermedios exactos.
RANDOM()no es lo mismo queRAND.RANDpertenece a la guía 9618, no a este programa de estudios.
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.
Errores comunes
ROUNDrecibe primero el valor y luego el número de lugares decimales.- En un trazado, registre los valores después de que se ejecute la línea, no los valores que espera que produzca la siguiente línea.
Now you try
- The first task is
ROUND. The second prints a trace, one row per line. - Press Check answer to test it.
Ahora practica
- La primera tarea es
ROUND. La segunda imprime un trazado, una fila por línea. - Pulse Comprobar respuesta para evaluarla.
Output · Salida ROUND(3.14159, 2) and · y ROUND(9.6, 0), each on its own line. · Emita ROUND(3.14159, 2) y ROUND(9.6, 0), cada uno en su propia línea.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.
Start · Inicio Total at 0. For I from 1 to · hasta 3, add I to · hasta Total and output I, a space, and Total on that line. The three lines are the trace. · Inicie Total en 0. Para I desde 1 hasta 3, añada I a Total y emita I, un espacio y Total en esa línea. Las tres líneas son la traza.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.