in Education by
Please tell me what random.seed() does in Python. For example, why do the below trials do what they do (consistently)? >>> import random >>> random.seed(9001) >>> random.randint(1, 10) 1 >>> random.randint(1, 10) 3 >>> random.randint(1, 10) 6 >>> random.randint(1, 10) 6 >>> random.randint(1, 10) 7 Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
random.seed() is used to initialize a pseudo-random number generator in python language. Pseudo-random number generator works by performing operations on a value. random.seed() will give the previous value for a pseudo-random number generator, for the first time it will not give any previous value. The generated values correspond to each seed value and so if you do the same seeding twice, the same sequence of numbers is generated twice. The seed value is very important as it generates a strong secret encryption key.

Related questions

0 votes
    What makes using range() to make the process of generating a quadrillion values in a instant of time, I am amazed by ... o += 1 return Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Here is a pure Python-specific design question: class MyClass(object): ... def get_my_attr(self): ... def ... you use and why? Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    Is there a built-in that removes duplicates from a list in Python, whilst preserving order? I know that I can ... idiom if possible. Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    Currently I am working on this code: customer_telno = customer.find('div', 'customer_phone_number') customer_telno = ... this problem? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I want to create a new list from the existing two lists that will have all the matches from list 2 which has an exact ... *", i) in a] Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    I can't decipher however the sklearn.pipeline.Pipeline works precisely. Some explanation in this documentation. What ... estimator)]) Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    What will be the output of the following Python function? min(max(False,-3,-4), 2,7) a) -4 b) -3 c) 2 d) False...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    I am looking for a way to return the interpolated coordinate value of a variable at a query variable value ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    def main(): for i in xrange(10**8): pass main() This piece of code in Python runs in (Note: The timing is ... sys 0m0.012s Why is this? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    How does one write a unittest that fails only if a function doesn't throw an expected exception? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    Many times I have seen the set.seed function in R, before starting the program. I know it's basically used for ... need to set this? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    Say I have a DataFrame full of positive samples and context features for a given user: target user cashtag ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    So for a HW assignment, we're making a Yahtzee game. At least part of it. For preparation, our ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    Generate random integers between 0 and 9 In Python, How do I generate random integers between 0 to 9 ? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    How can I generate a string of size N. I want it to be of uppercase English letters and numbers like this: 7I2D86 ... do it in Python. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
...