fork download
  1. import random
  2.  
  3. # Make a bingo column with numbers >= minx and < maxx
  4. def make_column(minx, maxx):
  5. return random.sample(range(minx, maxx), 5)
  6.  
  7. # Make a 2D list to represent a bingo card
  8. # Each sub-list is a column in the card
  9. def make_card():
  10. card = []
  11. for row in range(1, 75, 15):
  12. card.append(make_column(row, row + 15))
  13. card[2][2] = '--'
  14. return card
  15.  
  16. def print_card(card):
  17. print(" B I N G O")
  18. for i in range(5):
  19. for j in range(5):
  20. print(f"{card[j][i]:>2}", end = " ")
  21. print()
  22.  
  23. num_cards = int(input('Enter the number of Bingo cards to generate (1-10): '))
  24. print()
  25. def main():
  26. for _ in range(num_cards):
  27. card = make_card()
  28. print_card(card)
  29. print()
  30.  
  31. main()
Success #stdin #stdout 0.03s 11596KB
stdin
3
stdout
Enter the number of Bingo cards to generate (1-10): 
 B  I  N  G  O
 1 16 45 59 74 
 6 25 38 60 70 
14 26 -- 48 71 
12 30 33 54 72 
 5 24 35 50 65 

 B  I  N  G  O
 3 30 42 46 66 
 1 29 45 53 73 
14 19 -- 48 68 
12 22 31 56 61 
11 16 38 52 64 

 B  I  N  G  O
13 17 43 54 69 
15 25 33 56 66 
 8 18 -- 49 73 
 9 22 34 53 61 
12 24 41 52 62