Download The Random Module Randrange Randrange Randint Function

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Abuse of notation wikipedia , lookup

History of the function concept wikipedia , lookup

Function (mathematics) wikipedia , lookup

Non-standard calculus wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Infinite monkey theorem wikipedia , lookup

Karhunen–Loève theorem wikipedia , lookup

Law of large numbers wikipedia , lookup

Transcript
2/9/09 Randrange
•  randrange( [start,] stop [, step] )
The Random Module
–  Returns a randomly selected element from
the specified range
–  works with integers
Creates pseudo-random numbers
Coming up: Randrange
Randrange
•  randrange( [start,] stop [, step] )
Randint Function
•  randint(a,b)
–  returns a random integer N such that:
•  a ≤ N ≤ b
1 2/9/09 Choice function
•  choice( sequence )
–  Returns a random element from a nonempty sequence (e.g. a String)
Uniform Function
•  uniform(a,b)
–  Returns a random real number N such that:
Random function
•  random()
–  Returns the next random floating point
number in the range 0.0  1.0
How random is it?
•  Lets plot some random points and see
what it looks like
•  a ≤ N < b
•  randomTest/RandomTester.py
•  (Note: This code is to demonstrate
random only… we haven’t yet learned
many concepts used in the program)
2