How to build a Custom Bingo Board with Python

import matplotlib.pyplot as plt
import matplotlib.style as style
import random
%matplotlib inline
style.use('seaborn-poster')
states = ["AL - Alabama", "AK - Alaska", "AZ - Arizona", "AR - Arkansas", "CA - California", "CO - Colorado",
"CT - Connecticut", "DC - Washington DC", "DE - Deleware", "FL - Florida", "GA - Georgia",
"HI - Hawaii", "ID - Idaho", "IL - Illinios", "IN - Indiana", "IA - Iowa",
"KS - Kansas", "KY - Kentucky", "LA - Louisiana", "ME - Maine", "MD - Maryland",
"MA - Massachusetts", "MI - Michigan", "MN - Minnesota", "MS - Mississippi",
"MO - Missouri", "MT - Montana", "NE - Nebraska", "NV - Nevada", "NH - New Hampshire",
"NJ - New Jersey", "NM - New Mexico", "NY - New York", "NC - North Carolina",
"ND - North Dakota", "OH - Ohio", "OK - Oklahoma", "OR - Oregon", "PA - Pennsylvania",
"RI - Rhode Island", "SC - South Carolina", "SD - South Dakota", "TN - Tennessee",
"TX - Texas", "UT - Utah", "VT - Vermont", "VA - Virgina", "WA - Washington", "WV - West Virginia",
"WI - Wisconsin", "WY - Wyoming"]
terms = [s.split('-')[1].strip() for s in states]
t = 0
# Section 1
random.shuffle(terms) # Shuffles the list randomly for different boards
terms.insert(12,"Free")

rowlen= 5 # makes a 5x5 bingo board

##################################
# Section 2
fig = plt.figure()
ax = fig.gca()
ax.set_xticks(np.arange(0, rowlen + 1))
ax.set_yticks(np.arange(0, rowlen + 1))
ax.set_xticklabels([])
ax.set_yticklabels([])
plt.grid(color='black',linewidth=1)
################################
# Section 3
for i, word in enumerate(terms[:rowlen**2]):
x = (i % rowlen) + 0.5 - len(word)/50
y = int(i / rowlen) + 0.45
ax.annotate(word, xy=(x, y), xytext=(x, y))
plt.show()
random.shuffle(terms) # Shuffles the list randomly for different boards
terms.insert(12,"Free")
rowlen= 5 # makes a 5x5 bingo board
fig = plt.figure()
ax = fig.gca()
ax.set_xticks(np.arange(0, rowlen + 1))
ax.set_yticks(np.arange(0, rowlen + 1))
ax.set_xticklabels([])
ax.set_yticklabels([])
plt.grid(color='black',linewidth=1)
for i, word in enumerate(terms[:rowlen**2]):
x = (i % rowlen) + 0.5 - len(word)/50
y = int(i / rowlen) + 0.45
ax.annotate(word, xy=(x, y), xytext=(x, y))
plt.show()
import matplotlib.pyplot as plt
import matplotlib.style as style
import numpy as np
import random
get_ipython().run_line_magic('matplotlib', 'inline')
style.use('seaborn-poster')
######################################################
states = ["AL - Alabama", "AK - Alaska", "AZ - Arizona", "AR - Arkansas", "CA - California", "CO - Colorado",
"CT - Connecticut", "DC - Washington DC", "DE - Deleware", "FL - Florida", "GA - Georgia",
"HI - Hawaii", "ID - Idaho", "IL - Illinios", "IN - Indiana", "IA - Iowa",
"KS - Kansas", "KY - Kentucky", "LA - Louisiana", "ME - Maine", "MD - Maryland",
"MA - Massachusetts", "MI - Michigan", "MN - Minnesota", "MS - Mississippi",
"MO - Missouri", "MT - Montana", "NE - Nebraska", "NV - Nevada", "NH - New Hampshire",
"NJ - New Jersey", "NM - New Mexico", "NY - New York", "NC - North Carolina",
"ND - North Dakota", "OH - Ohio", "OK - Oklahoma", "OR - Oregon", "PA - Pennsylvania",
"RI - Rhode Island", "SC - South Carolina", "SD - South Dakota", "TN - Tennessee",
"TX - Texas", "UT - Utah", "VT - Vermont", "VA - Virgina", "WA - Washington", "WV - West Virginia",
"WI - Wisconsin", "WY - Wyoming"]
terms = [s.split('-')[1].strip() for s in states]########################################################
for t in range(1,51,1):
if t == 1:
random.shuffle(terms)
terms.insert(12,"Free")
else:
terms.pop(12)
random.shuffle(terms)
terms.insert(12,"Free")
rowlen= 5 # makes a 5x5 bingo boardfig = plt.figure()
ax = fig.gca()
ax.set_xticks(np.arange(0, rowlen + 1))
ax.set_yticks(np.arange(0, rowlen + 1))
ax.set_xticklabels([])
ax.set_yticklabels([])
plt.grid(color='black',linewidth=1)
for i, word in enumerate(terms[:rowlen**2]):
x = (i % rowlen) + 0.5 - len(word)/50
y = int(i / rowlen) + 0.45
ax.annotate(word, xy=(x, y), xytext=(x, y))

plt.show()
fig.savefig("C:/Users/name/Downloads/Bingo Cards/%s-Bingo.pdf" %t)

--

--

--

I am a Data Scientist graduate student excited about all aspects of computing, coding, and solving business problems.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

cs371g blog

Monitoring CI/CD Workflows

Productivity: What is Conway’s Law? Should we have small teams?

VNC Alternative for working on remote Linux machine

Automated Software Testing: Your Ultimate Guide

A future astrophysicist gets her CS start on Code.org

5 Websites to Learn Mobile App Development At your Own Pace

API Based Data Ingestion Using Local Nifi

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
J. Humms

J. Humms

I am a Data Scientist graduate student excited about all aspects of computing, coding, and solving business problems.

More from Medium

How to scrape Tweets about Bitcoin with Python and Twint

LexisNexis Newspaper Analysis in Python

Python in Healthcare — Good Health now depends on Code too!!

Obfuscation using Caesar cipher and ROT13 in Python