Programming is writing instructions that a computer can carry out. This topic covers the building blocks found in every language. Variables and constants store data of a type such as integer, real, string or Boolean. Sequence, selection and iteration control the order of steps: IF statements choose, and FOR, WHILE and REPEAT loops repeat. Arrays hold lists of values, and procedures and functions break a long program into parts. Programs also validate input, handle strings and read and write files. You practise these in pseudocode and in Python.
Roll ← ROUND(RANDOM() * 8, 0). Which values can Roll take?RANDOM() * 8 is from 0 to 8. Rounding to 0 places gives a whole number from 0 to 8.
0 is possible, so the range does not start at 1. 8 is possible, so it does not stop at 7. ROUND with 0 places gives whole numbers only.Log in to join the discussion.
Loading…