In the Lotto, two numbers, one from 1 - 30 and a second from 31 - 60 are chosen, with each choice independent from the other and each of the possible numbers is equally likely to be chosen. If you match one number you receive $5 and if you match both numbers you receive $500. It costs $1 per play. Write a program that simulates playing the Lotto one million times. At the end of the simulation, print out the following:
1) The number of times exactly one number was matched.
2) The number of times exactly two numbers were matched.
3) The amount of money lost after buying the million lotto tickets.
For your simulation, you'll choose one winning lotto combination. Then, you'll simulate randomly choosing a million tickets, tallying up the winnings of each ticket.
Note: If you write the simulation properly, there is virtually no chance that you'll make money.
Sample Program Run:
You matched 1 number 64222 times.
You matched 2 numbers 1107 times.
You lost $125390.
I have this so far:
import random Match_One_Number = $5 Match_Two_Numbers = $500 Cost_Per_Play = $1 MAX_LOTTO_NUM1 = 30 MAX_LOTTO_NUM2 = 60 NUM_LOTTO_TRIALS = 1000000 def main(): # Seed the random number generator. random.seed() count = 0 total = 0 # Run the game NUM_LOTTO_TRIALS times. # def playLotto(): # Get first Lotto number. LOTTO_NUM1 = random.randint (1, MAX_LOTTO_NUM1) # Get second Lotto number. LOTTO_NUM2 = random.randint (31, MAX_LOTTO_NUM2)