
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 2)
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 6–9
- 6
A developer is building a recommendation system that needs to randomly select 5 items from a catalog of 1000 items for a user. The selection must be reproducible for a given user ID. The developer writes: ```python random.seed(user_id) recommendations = random.sample(catalog, 5) ``` Later, the developer discovers that the same user always gets the same 5 recommendations, but the requirement is that the user should get a different set of recommendations each time they visit, while still being reproducible for debugging. Which approach should the developer take?
Select an answer first - 7
A developer is writing a test that needs to generate a random float in [0.0, 1.0) to simulate a sensor reading. The test must be deterministic so that the same sequence of readings is produced every time the test runs. Which code should the developer write?
Select an answer first - 8
What is the primary purpose of calling random.seed(42) before generating random numbers?
Select an answer first - 9
A developer is writing a quiz application that presents questions in a random order. The developer wants to use the same random order for a given user across multiple sessions, but different users should get different orders. The user ID is an integer. Which approach should the developer take?
Select an answer first
Finished these 4 questions?
Review the revealed explanations, or continue through the curriculum.
No more pagesBack to PCAP-31
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.