Introductory Programming in Python: Lesson 17
Random Numbers

[Prev: More on Command Line Arguments] [Course Outline] [Next: Files for Input and Output]

Exploring the random Module Further

Although nearly everything the random module does is based on obtaining a single random number, the module provides us with a number of convenience functions, that take the tedium from doing common 'random' tasks. Functions are provided which return random integers in given ranges, random choices from sequences, or produce random permutations of a sequence. In addition there are some fairly useful distribution functions, which pull random number from chosen distributions with specified parameters.

Let's deal with the integers first.

The true convenience of the random module becomes apparent with the three sequence functions.

Exercises

[Prev: More on Command Line Arguments] [Course Outline] [Next: Basic Parsing]