1 Replies - 631 Views - Last Post: 14 September 2012 - 09:19 PM Rate Topic: -----

#1 beltway  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-September 12

Problem with how to use the program.

Posted 14 September 2012 - 07:46 PM

Hey guys, I'm having difficulty writing this program for my homework and I am a little confuse as to how to continue to write the program. Can someone please help me? the specification is as follows:

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)





Is This A Good Question/Topic? 0
  • +

Replies To: Problem with how to use the program.

#2 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1156
  • View blog
  • Posts: 2,538
  • Joined: 05-May 05

Re: Problem with how to use the program.

Posted 14 September 2012 - 09:19 PM

1. Ok, so you need to call playlotto in a loop and accumulate the winnings. So perhaps you could have playlotto return the money won or lost (negative number).
2. The directions said you to define two lottery picks for all drawings to be compared against. You need to do that, and in playlotto use the random numbers you generate to detect a match.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1