Browse By Unit
1 min readβ’june 18, 2024
Minna Chow
Milo Chang
Minna Chow
Milo Chang
Many coding languages provide a way to generate random numbers, and College Board's Pseudocode is no exception. It's a good tool for many programs.
Here's what the random generator looks like in Pseudocode:
import random
c = random.randint(a,b)
Notice how you have to import the random module into your program in order to gain access to the random generator.Β
The Python example above will generate a random integer from a to b, inclusive. For example,Β c = random.randint(0,5) could result in the value ofΒ c being 0, 1, 2, 3, 4, or 5.Β
Using random number generation in a program means that we might get a different result every time we run the program.
One example where random value generators come into handy is in simulations, which we'll discuss inΒ Topic 3.16.
<< Hide Menu
1 min readβ’june 18, 2024
Minna Chow
Milo Chang
Minna Chow
Milo Chang
Many coding languages provide a way to generate random numbers, and College Board's Pseudocode is no exception. It's a good tool for many programs.
Here's what the random generator looks like in Pseudocode:
import random
c = random.randint(a,b)
Notice how you have to import the random module into your program in order to gain access to the random generator.Β
The Python example above will generate a random integer from a to b, inclusive. For example,Β c = random.randint(0,5) could result in the value ofΒ c being 0, 1, 2, 3, 4, or 5.Β
Using random number generation in a program means that we might get a different result every time we run the program.
One example where random value generators come into handy is in simulations, which we'll discuss inΒ Topic 3.16.
Β© 2024 Fiveable Inc. All rights reserved.