Concepts·Certified Associate Python Programmer
Python random Module
PCAP objective 1.3 is generate random values using the random module. The functions are short and the two things examined are their bounds - `randint` includes both ends and `randrange` does not - and the seed, which makes the sequence reproducible. Every example on this page is seeded, because an unseeded one could not be shown with its output at all.
Modules and Packages Guide 6 of 25 Intermediate
- Python3.14.4
- OSUbuntu 26.04 LTS
- pip25.1.1
- TimeAbout 14 min
- Reviewed23 August 2026
Written against the versions above. `random.sample` no longer accepts a set as its population (removed in Python 3.11); pass a list or a range. Everything else the syllabus names is unchanged.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RUNNER01 | 192.168.0.27 | Ubuntu 26.04 LTS | Python 3.14.4 - the only machine this path needs | 2 Core | 4 GB | 50 GB |
Before you start
-
The functions, with the seed fixed
-
The same seed gives the same numbers
-
With no seed, the numbers differ between runs
-
randint includes both ends, randrange does not
-
shuffle changes the list, sample does not
-
How random refuses
-
What the exam does with this objective