-
Notifications
You must be signed in to change notification settings - Fork 0
/
bingo_card.py
61 lines (45 loc) · 1.1 KB
/
bingo_card.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def bingo_card():
"""
This funtion generates and return dictionary as
Bingo card.
@param: None
@return: dictionary.
"""
import random
# Declare variables.
char = ['B', 'I', 'N', 'G', 'O']
card = dict()
start = 1
stop = 15
# Populate card with key-value pair.
for c in char:
card[c] = random.sample(range(start, stop), 5)
start += 15
stop += 15
# Return Bingo card as a dictionary.
return card
def disp(card):
"""
This function takes card, a dictionary as argument
and prints it as a bingo card.
@param: dictionary
@return: None
"""
# Declare variables.
card = bingo_card()
i = 0
# Print the card headers.
for key in card.keys():
print(key, end='\t')
print('\n----------------------------------')
# Print the card body.
for j in range(len(card)):
for key in card.keys():
print(card[key][i], end='\t')
i += 1
print()
def main():
# Create and display Bingo card.
disp(bingo_card())
if __name__ == "__main__":
main()