Python Bibliotheca
Python resources for teachers and students.

Powerball number generator


To win the Powerball lottery (an extremely unlikely event so don't waste your time) you have to pick six numbers correctly. The first five numbers are drawn from a drum containing 53 balls and the sixth is drawn from a drum containing 42 balls. The chances of doing this are 1 in 120,526,770. Write a program to generate a set of Powerball numbers by utilizing the choice function in Python's random module.


Ask the user how many sets of Powerball numbers he or she would like.


The program will print each set of Powerball numbers in numeric order.

Sample session

Official (but fruitless) Powerball number generator

How many sets of numbers? 3

Your numbers:  3 12 14 26 47     Powerball:  2
Your numbers:  1  4 31 34 51     Powerball: 17
Your numbers: 10 12 49 50 53     Powerball: 35

[ Copyright 2003, Tim Wilson ]

Comments, questions, or suggestions? Email the webmaster