CertGrid CertGrid
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

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.

One machine, and any shell with Python 3 will do - these exams test the language, not a distribution.
Server NameIP AddressOSRolesCPURAMHDD
RUNNER01192.168.0.27Ubuntu 26.04 LTSPython 3.14.4 - the only machine this path needs2 Core4 GB50 GB

Before you start

  1. The functions, with the seed fixed

  2. The same seed gives the same numbers

  3. With no seed, the numbers differ between runs

  4. randint includes both ends, randrange does not

  5. shuffle changes the list, sample does not

  6. How random refuses

  7. What the exam does with this objective

Official sources