πŸ“š

All Subjects

Β >Β 

⌨️ 

AP Comp Sci P

Β >Β 

πŸ“±

Big Idea 3: Algorithms and Programming

Random Values

1 min readβ€’november 16, 2020

minnachow

Minna Chow


AP Computer Science Principles ⌨️

BookmarkedΒ 2.9kΒ β€’Β 79Β resources
See Units

Generating Random Numbers

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:
https://firebasestorage.googleapis.com/v0/b/fiveable-92889.appspot.com/o/images%2F-BY9uvRHSYeXU.png?alt=media&token=c40ab8ec-13e2-4cf1-ad5e-1f59b1dbd561
...and here's its equivalent in Python:
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.
One example where random value generators come into handy is in simulations.

Was this guide helpful?

Fiveable logo
Join Fiveable for free
Create a free account to bookmark content and compete in trivia
Hours Logo
Studying with Hours = the ultimate focus mode
Start a free study session
Browse Study Guides By Unit
πŸ•ΉBig Idea 1: Creative Development
βš™οΈBig Idea 2: Data
πŸ“±Big Idea 3: Algorithms and Programming
πŸ–₯Big Idea 4: Computer Systems and Networks
⌨️Big Idea 5: Impact of Computing
✏️Frequently Asked Questions
πŸ“Exam Prep
πŸ“± Stressed or struggling and need to talk to someone?
Talk to a trained counselor for free. It's 100% anonymous.
Text FIVEABLE to 741741 to get started.
Β© 2021 Fiveable, Inc.