Python Forum
How to Generate and Print An Array with Random Numbers in Python in the
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Generate and Print An Array with Random Numbers in Python in the
#1
I am a beginner in Django. I am trying to solve a Bingo card game problem, where I have to generate an array and print the random numbers without any duplication.

I have to print this output:

     W      O      R      L      D 
W   10     93     85     14     18    
O   24     96     88     29     23    
R   36     33     99     90     31     
L   46     48     92     95     43     
D   59     76     51     72     58   
It's a bingo game. The card gets filled with random Numbers. I have tried the following codes:

import random

class Card:
    def __init__(self):
        self.b = random.sample(range(1,100),5)
        self.i = random.sample(range(1,100),5)
        self.n = random.sample(range(1,100),5)
        self.g = random.sample(range(1,100),5)
        self.o = random.sample(range(1,100),5)

        print(self.b)
        print(self.i)
        print(self.n)
        print(self.g)
        print(self.o)
The codes don't deliver the desired output.
Reply


Messages In This Thread
How to Generate and Print An Array with Random Numbers in Python in the - by johnnynitro99293 - Sep-17-2019, 11:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Random Generator: From Word to Numbers, from Numbers to n possibles Words Yamiyozx 2 1,486 Jan-02-2023, 05:08 PM
Last Post: deanhystad
  random interger array question rpang 3 1,896 Nov-05-2022, 12:31 PM
Last Post: deanhystad
  Convert list of numbers to string of numbers kam_uk 5 3,090 Nov-21-2020, 03:10 PM
Last Post: deanhystad
  Getting largest indices of array less than or equal to an array of numbers schniefen 5 2,698 Nov-02-2020, 08:14 PM
Last Post: schniefen
  Scaling random numbers within specific range schniefen 4 3,242 Oct-28-2019, 11:22 AM
Last Post: jefsummers
  python homework print the sum of a range of numbers from x to y kirito85 3 3,306 Oct-28-2018, 08:56 AM
Last Post: kirito85
  10x10 Array of Prime Numbers smfox2 1 2,575 Sep-03-2018, 12:36 AM
Last Post: ichabod801
  random numbers and stats cliffhop23 2 6,962 Feb-22-2018, 09:16 PM
Last Post: glidecode
  Regular Expressions in Files (find all phone numbers and credit card numbers) Amirsalar 2 4,157 Dec-05-2017, 09:48 AM
Last Post: DeaD_EyE
  NEED HELP Pseudo-Random Numbers Kongurinn 9 5,544 Oct-23-2017, 04:17 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020