To play the PowerBall lottery, you buy a ticket that has five numbers in the range of

Question:

To play the PowerBall lottery, you buy a ticket that has five numbers in the range of 1–69, and a “PowerBall” number in the range of 1–26. (You can pick the numbers yourself, or you can let the ticket machine randomly pick them for you.) Then, on a specified date, a winning set of numbers is randomly selected by a machine. If your first five numbers match the first five winning numbers in any order, and your PowerBall number matches the winning PowerBall number, then you win the jackpot, which is a very large amount of money. If your numbers match only some of the winning numbers, you win a lesser amount, depending on how many of the winning numbers you have matched.

In the student sample programs for this book, you will find a file named pbnumbers.txt, containing the winning PowerBall numbers that were selected between February 3, 2010 and May 11, 2016 (the file contains 654 sets of winning numbers). Figure 8-6 shows an example of the first few lines of the file’s contents. Each line in the file contains the set of six numbers that were selected on a given date. The numbers are separated by a space, and the last number in each line is the PowerBall number for that day. For example, the first line in the file shows the numbers for February 3, 2010, which were 17, 22, 36, 37, 52, and the PowerBall number 24.


i have gotten the fist 2 question but i cant figue out how to get the most over due numbers in the list this is my code so far

import collections infile=open('pbnumbers.txt','r') lines=infile.readlines() infile.close() winninglist=[] for i in range(len(lines)):    item=lines[i].split()    winninglist+=item counter=collections.Counter(winninglist) print(counter.most_common(10)) print(counter.most_common()[:-10-1:-1])

Figure 8-6 The pbnumbers.txt file pbnumbers.txt - Notepad File Edit Format View Help 17 22 36 37 52 24 14 22

Write one or more programs that work with this file to perform the following:

• Display the 10 most common numbers, ordered by frequency

• Display the 10 least common numbers, ordered by frequency

• Display the 10 most overdue numbers (numbers that haven’t been drawn in a long time), ordered from most overdue to least overdue

• Display the frequency of each number 1–69, and the frequency of each Powerball number 1–26

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: