|
| 1 | +import random |
| 2 | + |
| 3 | +# winning_lotto_number = [] # Placing variable with empty List of to hold numbers |
| 4 | + |
| 5 | +# for i in range(1 , 7): #creating a forloop to be repeated 6 times |
| 6 | +# numbers = random.randint (1,99) #generating random numbers between 1 and 99 |
| 7 | + |
| 8 | +# winning_lotto_number.append(numbers) # getting all the numbers that were generated from the top and putting them in to the list of lottonumbers |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +# users_attempt = [] #same thing as before just putting a place holder for the numbers that will be inputed |
| 13 | + |
| 14 | +# for i in range(1,7): #for loop getting ready to as the user 6 times to input a number rather than typing the same thing 6 times |
| 15 | +# numbers = random.randint (1,99) |
| 16 | + |
| 17 | +# users_attempt.append(numbers) if you have to make one of these twice, indicates that you should just use a function |
| 18 | + |
| 19 | +def number_picker(): |
| 20 | + numbers = [] #something to put the nums in |
| 21 | + for i in range(1,7): #Should run the loop 6 times |
| 22 | + numbers.append(random.randint (1,99)) |
| 23 | + return numbers |
| 24 | + |
| 25 | + |
| 26 | +def compare(winning_ticket, current_ticket): |
| 27 | + counter = 0 #keeping track of how many matches |
| 28 | + for i in range(6): #checking the index of the two arguments range is returning an array which starts at the index of 0 and then goes up to 5 |
| 29 | + if winning_ticket[i] == current_ticket[i]:# running the 6 times |
| 30 | + counter +=1 # counting how many match |
| 31 | + return counter |
| 32 | + |
| 33 | + |
| 34 | +# print(compare(number_picker(), number_picker())) |
| 35 | + #test |
| 36 | +winner = number_picker() # winning ticket on the outside so it stays constant |
| 37 | +balance = 0 # Holder |
| 38 | + |
| 39 | +for i in range(100000): |
| 40 | + comparing_tickets = compare(number_picker(), winner) #i'm getting my compare function putting my number_picker funtion with in it which is the one thats gonna be getting changed the 100,000 time and comparing it to the winner which is the one that will be staying the same all those times |
| 41 | + balance -= 2 # since the balnce on top is the holder im making it -2 since that is how much it is to pay for a ticket |
| 42 | + if comparing_tickets == 1: # if one of the compared matches has one match in the same spot we get $2 since we were already losing 2 |
| 43 | + balance += 4 |
| 44 | + elif comparing_tickets == 2: |
| 45 | + balance += 7 |
| 46 | + elif comparing_tickets == 3: |
| 47 | + balance += 100 |
| 48 | + elif comparing_tickets == 4: |
| 49 | + balance += 50,000 |
| 50 | + elif comparing_tickets == 5: |
| 51 | + balance += 1,000,000 |
| 52 | + elif comparing_tickets == 6: |
| 53 | + balance += 25,000,000 |
| 54 | + |
| 55 | +return_of_in = balance / 200000 # getting the balance and then dividing it bt the 200,000 because thats the two dollars to buy the ticket and multiplying it by the many times we're gonna but the ticket |
| 56 | +print(f'The winning lotto numbers are {winner}') |
| 57 | +print(f'\n and your balance is {balance}') |
| 58 | +print(f'Your ROI is {return_of_in}') |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +# print(users_attempt) |
| 65 | +# print (winning_lotto_number) |
| 66 | + #test |
| 67 | + |
0 commit comments