Question: You can use the random module's seed function to seed the random - number generator yourself this forces randrange to begin calculating its pseudorandom number
You can use the random module's seed function to seed the randomnumber generator yourselfthis forces randrange to begin calculating its pseudorandom number sequence from the seed you specify. Choosing the same seed will cause the random number generator to generate the same sequence of random numbers.
In the following session, snippets and produce the same results purely by coincidence:
In : random.seed
In : for roll in range:
: printrandomrandrange end
:
In : for roll in range:
: printrandomrandrange end
:
In : random.seed
In : for roll in range:
: printrandomrandrange end
:
When you're debugging logic errors in programs that use randomly generated data, it can be helpful to use the same sequence of random numbers until you've eliminated the logic errors, before testing the program with other values.
Function randrange actually generates pseudorandom numbers, based on an internal calculation that begins with a numeric value known as a seed.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
