Examers.io
ExamsOrganizationsHow it worksPricingHelp & FAQ
Python Institute logo

Python InstitutePCAP - Certified Associate Python Programmer

Domain 1Objective 3

PCAP-31-03 1.3 Generate Random Values Using the Random Module PCAP-31 Practice Questions (Page 1)

Part of the Modules and Packages domain, which accounts for 12% of the PCAP-31 exam. Python Institute does not publish an official question count, but from its 65-minute exam (~25–45 total, ~3–5 in this domain), expect 1–1 from this objective — we provide 9 practice questions to prepare you well beyond it. (estimate)

9questions here
2free pages
4concepts
12%of the exam

Questions 1–5

  1. 1foundation · easy

    What is the range of possible values that can be returned by a call to random.random()?

    Select an answer first
  2. 2foundation · easy

    What happens if you call random.choice([]) with an empty list?

    Select an answer first
  3. 3expert · hard

    A developer is writing a simulation that uses random.random() to generate probabilities and random.choice() to select events. The simulation must be reproducible when a specific seed is provided, but must use a different seed on each run when no seed is provided. The developer writes the following code: ```python import random import sys if len(sys.argv) > 1: random.seed(int(sys.argv[1])) else: random.seed() # simulation code using random.random() and random.choice() ``` The developer runs the simulation twice with the same seed and gets different results. What is the most likely cause?

    Select an answer first
  4. 4foundation · easy

    Given the list colors = ['red', 'green', 'blue'], which expression returns a single random color from the list?

    Select an answer first
  5. 5expert · hard

    A data analyst is writing a script to randomly split a dataset of 1000 rows into a training set (700 rows) and a test set (300 rows). The split must be reproducible, and the two sets must not overlap. The analyst writes: ```python random.seed(42) train = random.sample(data, 700) test = random.sample(data, 300) ``` The analyst discovers that some rows appear in both train and test. What is the most likely cause?

    Select an answer first
Finished these 5 questions?

Review the revealed explanations, or continue through the curriculum.

Free Basic Practice is a study aid with revealable answers — not a scored exam. Examers.io is independent and not affiliated with or endorsed by Python Institute. “PCAP-31” is a trademark of its owner, used for identification only.