- Sometimes you need to create random numbers to make ‘lucky dip’ choices from lists
- To create a random integer (whole number) you can use the code below:
#Put this at the top of your file (only once)
import random
#Generates a random number between 1 and 100
number = random.randint(1,100)
#Print the number
print(number)
Tasks
- Create a program to simulate a lottery draw. It should generate 6 numbers between 1-49 and print them appropriately
- Run the program multiple times. Why will this program not be suitable for drawing lottery numbers?
- Save and label your code
Extension Task
Can you figure out a way of picking six unique numbers for the lottery draw?