ROUND, RANDOM and a trace · ROUND, RANDOM, dan jejak
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.
Toko membulatkan harga
ROUND(Value, Places)mengembalikanValueyang dibulatkan kePlacestempat desimal.Placesadalah bilangan bulat.ROUND(3.14159, 2)adalah3.14.ROUND(9.6, 0)adalah bilangan bulat10.- Silabus mencantumkan
ROUNDdenganDIV,MODdanRANDOM.
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.
Dadu menggunakan RANDOM
RANDOM()mengembalikan bilangan riil dari 0 hingga 1, termasuk kedua ujung. Setiap jalannya bisa berbeda.- Dadu permainan papan adalah
ROUND(RANDOM() * 6, 0). Kertas menggunakannya saat hasilnya mungkin bervariasi, sehingga Anda tidak diminta memberikan satu output tetap.
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 |
Isi tabel jejak
- Tabel jejak adalah simulasi kering. Satu baris adalah satu kali perulangan loop. Anda menulis variabel setelah perulangan tersebut.
Totaldimulai dari 0. SetelahI = 1menjadi 1. SetelahI = 2menjadi 3. SetelahI = 3menjadi 6.
| I | Total |
|---|---|
| 1 | 1 |
| 2 | 3 |
| 3 | 6 |
One row per pass · Satu baris per lompatan
A trace table records each variable after that pass of the loop. Here Total is the running sum of I. · Tabel jejak mencatat setiap variabel setelah lompatan loop itu. Di sini Total adalah total berjalan dari 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.
Hati-hati
- Bulatkan setengah hanya setelah Anda memeriksa digit. Tugas-tugas di sini bukan pada nilai tengah.
RANDOM()bukanRAND.RANDmilik panduan 9618, bukan silabus ini.
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.
Kesalahan umum
ROUNDmengambil nilai terlebih dahulu dan jumlah tempat secara kedua.- Dalam jejak, catat nilai setelah baris telah dijalankan, bukan nilai yang Anda harapkan akan dihasilkan oleh baris berikutnya.
Now you try
- The first task is
ROUND. The second prints a trace, one row per line. - Press Check answer to test it.
Sekarang Anda coba
- Tugas pertama adalah
ROUND. Tugas kedua mencetak jejak, satu baris per baris. - Tekan Cek jawaban untuk mengujinya.
Output ROUND(3.14159, 2) and ROUND(9.6, 0), each on its own line. · Outputkan ROUND(3.14159, 2) dan ROUND(9.6, 0), masing-masing pada barisnya sendiri.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.
Start 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. · Mulai Total pada 0. Untuk I dari 1 hingga 3, tambahkan I ke Total dan output I, spasi, dan Total pada baris itu. Tiga baris tersebut adalah jejaknya.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.