Random Numbers Flashcards

1️⃣ Familiarise yourself with the flashcards:

  • Look through all the flashcards to see what's on both sides.
  • Make sure you understand the information on each card. If something's unclear, click the link to the revision notes at the bottom of the page for more details.

2️⃣ Test yourself:

  • Look at the question or prompt on each card and try to remember the answer before flipping it over.
  • Check the answer and make a note of any cards you find challenging and need to go over more.

3️⃣ Consistently Review and Practice:

  • Use spaced repetition: spend more time on the cards you struggle with and go over them more often.
  • Regularly review all the flashcards to help you better understand and retain the information over time.

Note: We may include questions that have multiple correct answers. It's useful to remember specific examples to understand these concepts better.

PERSONALISED 1-TO-1 TUTORING

Need more help on this topic? Get 1-to-1 support

Get support with clear explanations, practice and feedback (Ages 5 to 16).

  • DBS-checked tutors
  • Flexible times
  • Parents can be updated

Want an ad-free experience? Subscribe to remove ads

What is a random number in programming?

A number the program picks by chance, using a random function.

What does pseudorandom mean?

Numbers look random but are made by a fixed method.

Which function gives a random whole number in a range?

RANDOM_INT(low, high) returns an integer from low to high, inclusive.

Which function gives a random decimal between 0 and 1?

RANDOM() returns a real number from 0 up to, but not including, 1.

How do you simulate a fair six-sided dice roll?

Call RANDOM_INT(1, 6). Each number 1 to 6 has the same chance.

How can you pick a random item from a list?

Choose a random index: i = RANDOM_INT(0, length-1). Then use list[i].

What is a seed in random number generation?

A starting value that fixes the sequence. The same seed repeats it.

Why set a seed when testing a program?

It makes random results repeat, so tests give the same outputs.

What is a uniform random choice?

Each allowed value has an equal chance of being chosen.

How can you get a random integer 1 to 10 using RANDOM()?

Multiply RANDOM() by 10, take the whole number part, then add 1.

What common mistake causes off-by-one errors with random ranges?

Forgetting whether the upper bound is included in the range.

How can you get a random True or False value?

Use RANDOM_INT(0, 1): 0 means False, 1 means True. Or use RANDOM() < 0.5.