Return to site

Bingo cards random numbers 1 75

broken image

And, in fact the specification for a Python set says that the numbers will be unordered. That looks OK, but the numbers should be in random order. So, to prevent duplicates, we could just add the numbers to a set, which eliminates duplicates, and add them until we have five: bset=set()Īnd this will give us sets of non-repeating numbers, such as

broken image

This looks pretty straightforward, but sometimes it prints out duplicate numbers like this one: This looks like an easy challenge for a Python program, so lets just see how we could generate 5 random numbers for the first column: The first column as 5 random numbers from 1 to 15, the second from 16 to 30 and so forth, with the last column being from 61 to 75. The five columns are labeled B, I, N, G and O. A Bingo card is just a 5 x 5 matrix of random numbers.

broken image