You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1 Python/labs/05 Pick6
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,9 @@ Have the computer play pick6 many times and determine net balance.
4
4
5
5
Initially the program will pick 6 random numbers as the 'winner'. Then try playing pick6 100,000 times, with the ticket cost and payoff below.
6
6
7
-
A ticket contains 6 numbers, 1 to 99, and the number of matches between the ticket and the winning numbers determines the payoff. Order matters, if the winning numbers are [5, 10] and your ticket numbers are [10, 5] you have 0 matches. If the winning numbers are [5, 10, 2] and your ticket numbers are [10, 5, 2], you have 1 match. Calculate your net winnings (the sum of all expenses and earnings).
7
+
A ticket contains 6 numbers, 1 to 99, and the number of matches between the ticket and the winning numbers determines the payoff.
8
+
Order matters, if the winning numbers are [5, 10] and your ticket numbers are [10, 5] you have 0 matches.
9
+
If the winning numbers are [5, 10, 2] and your ticket numbers are [10, 5, 2], you have 1 match. Calculate your net winnings (the sum of all expenses and earnings).
8
10
9
11
a ticket costs $2
10
12
if 1 number matches, you win $4
@@ -14,7 +16,8 @@ A ticket contains 6 numbers, 1 to 99, and the number of matches between the tick
14
16
if 5 numbers match, you win $1,000,000
15
17
if 6 numbers match, you win $25,000,000
16
18
17
-
One function you might write is pick6() which will generate a list of 6 random numbers, which can then be used for both the winning numbers and tickets. Another function could be num_matches(winning, ticket) which returns the number of matches between the winning numbers and the ticket.
19
+
One function you might write is pick6() which will generate a list of 6 random numbers, which can then be used for both the winning numbers and tickets.
20
+
Another function could be num_matches(winning, ticket) which returns the number of matches between the winning numbers and the ticket.
18
21
Steps
19
22
20
23
Generate a list of 6 random numbers representing the winning tickets
0 commit comments