Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Generate only one random number for many tries
Normally we use
import random
print(random.randint(1000, 9999)
To generate a number in the range. But I want a number which we generate at random but can be used for how many times ever we run the code.
What do you mean? Do you want to generate the same value every time you run the code, or something else? If that is what you mean, call random.seed to set the seed to whatever constant value you want.
Thank you
I got the expected output after using
import random

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Help with a random number generator dpcalder 2 113 Jun-20-2020, 03:50 AM
Last Post: buran
  Can i prevent the random generator to generate already used numbers? MauserMan 3 326 Jan-05-2020, 04:44 PM
Last Post: MauserMan
  generate random variables based on a non-standard t-distribution nathalie 4 384 Dec-03-2019, 12:11 AM
Last Post: scidam
  Finding MINIMUM number in a random list is not working Mona 5 407 Nov-18-2019, 07:27 PM
Last Post: ThomasL
  same number everytime when using random.randint summeringpainting 5 1,033 Aug-23-2019, 11:01 AM
Last Post: Malt
  Need to generate random numbers Gateux 8 634 Jul-19-2019, 03:37 PM
Last Post: Man_from_India
  Generate unique random numbers from different lists Takeshio 5 643 May-24-2019, 07:29 PM
Last Post: ichabod801
  help cant do random number nonzzo 1 507 Mar-28-2019, 07:33 PM
Last Post: Yoriz
  problems with random number/string PrasadPython 3 512 Mar-01-2019, 06:00 PM
Last Post: ichabod801
  random number anasa 2 853 Nov-26-2018, 08:56 PM
Last Post: Excelsiscelia

Forum Jump:

Users browsing this thread: 1 Guest(s)