🎲 Notes: Random Number Generation & Simulations


🔑 Key Concepts

  • Random Number Generation: Creating unpredictable values used in:
    • Simulations
    • Games
    • Security (e.g., passwords, encryption)
    • Testing/experiments
  • RANDOM(a, b): Returns a random integer from a to b (inclusive)
    • Equal probability for each number
    • Different each time it’s run

⚙️ Simulator Code Example

```python import random

def random_int(a, b): return random.randint(a, b)

print(f”1-10: {random_int(1, 10)}”) print(f”0-1: {random_int(0, 1)}”) # Coin flip print(f”1-6: {random_int(1, 6)}”) # Die roll