Tambola, sometimes called Indian Bingo or Housie is one of the most common games played in parties, sometimes with money. However, it requires numbered sheets or tickets which are a headache to buy, especially when you have a lot of people coming over. So, why not let Python do some of the work. Here is a program that can generate n Tambola tickets, so you will be ready before your next game. The main things to note are:
1. Numbers between 0-10 should be in col.1, 10-20 should be in col.2 and so on
2. Max. allowed is only 3 numbers between every 10 numbers
Keeping these points in mind, Try the code for yourself or check down below
Code:
1. Numbers between 0-10 should be in col.1, 10-20 should be in col.2 and so on
2. Max. allowed is only 3 numbers between every 10 numbers
Keeping these points in mind, Try the code for yourself or check down below
Code:
def bingo(): import random n = int(input("How many tickets do you need: ")) print('\n\nNote: "OO" signifies Empty Space\n\n') for n1 in range(n): tkt = [[' OO ',' OO ',' OO ',' OO ',' OO ',' OO ',' OO ',' OO ',' OO '], [' OO ',' OO ',' OO ',' OO ',' OO ',' OO ',' OO ',' OO ',' OO '], [' OO ',' OO ',' OO ',' OO ',' OO ',' OO ',' OO ',' OO ',' OO ']] d={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0} l = [] while 1<2: a = random.randint(1,89) if a not in l: if d[int(a/10)] < 3: l.append(a) d[int(a/10)] += 1 if len(l) == 15: break for x in l: x1 = int(x/10) if int(x/10) == 0: x2 = str(f' 0{str(x)} ') else: x2 = str(f' {str(x)} ') while 1<2: a = random.randint(0,2) if tkt[a][x1] == ' OO ': tkt[a][x1] = x2 break print(f"Ticket No. {n1+1}\n") for i in tkt: print(*i) print('\n\n\n') a = input('Press Enter to Quit') bingo()
Output:
How many tickets do you need: 2 Note: "OO" signifies Empty Space Ticket No. 1 09 OO 23 38 OO OO OO 70 84 OO 19 OO OO OO OO 66 77 86 OO OO 24 39 43 OO 63 79 88 Ticket No. 2 OO 10 OO 34 49 OO 60 76 OO 02 OO OO OO OO 53 61 72 81 01 19 OO OO OO OO 66 75 83 Press Enter to Quit >>>
With this awesome program, you can wave goodbye to all your ticket-buying woes and enjoy a game with your friends and family. Do follow the Pygrammer if you like this post and make sure to check out other posts for more simple but interesting programs and tutorials.
Want to check out other games and know how to program them with Python: Games Compilation
Want to learn how to plot graphs with Python: How to plot graphs with Python
Want to know how to program an instant Anagram Solver: Anagram Finder
The blog is very informative, You have shared a such a nice info..
ReplyDeleteThank You,