Bingo V1 (Python)

In the United Kingdom (UK) there is a game called Bingo which involves a caller randomly choosing a number between 1 and 90, calling out the number and then placing it so that it cannot be called again. Players have cards in front of them with 15 randomly chosen numbers (between 1 and 90) on them. If a player has the called out number they mark it of on their game card, until a line of number, 2 lines of numbers or a full house (all 15 numbers) occurs.

More information on Bingo can be found at https://en.wikipedia.org/wiki/Bingo_(United_Kingdom)

My Bingo V1 Python program is going to generate numbers in a range of 1 to 90 and not display any duplicate numbers:

__________________

#!/bin/python3
#geektechstuff
#Bingo

#libraries to import

#randint generates a random integer
from random import randint
#time is here so that sleep can be used to cause a wait between draws
import time

 

#Bingo in the UK uses the numbers 1 to 90
for draw in range(90):
#as numbers are generated they are added to a list to stop duplication
drawn_numbers=list()
#generates a random integer between 1 and 90
bingo_draw=randint(1,90)
#if the number is already in the list it is discarded
if not bingo_draw in drawn_numbers:
print(bingo_draw)
#append to add the number to the list
drawn_numbers.append(bingo_draw)
#wait inbetween each draw
time.sleep(10)

_______________

For the V2 of the program I want to:

  • Add in escape keys for winning conditions (i.e. caller presses H for full house, L for line, 2 for 2 Lines etc…
  • Generate the numbers into a window rather than print them into the Python console.

 

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.