Knowledge organisersRandom Number Generation
Generate numbers in range.
Use random.randint(a, b) to generate a random integer between a and b inclusive. You must import random first.
import random at the top of the programrandom.randint(1, 6) gives 1, 2, 3, 4, 5, or 6import random
dice = random.randint(1, 6)
print("You rolled: " + str(dice))
coin = random.randint(0, 1)
print("Heads" if coin == 1 else "Tails")