PCAP-31-04

PCAP - Assoc. Python Programmer (PCAP-31-04) practice exams

290 questions in 5 timed practice tests. Each test has about 62 questions and a 90-minute limit. The pass mark is 72%. Results are split across the 6 exam domains.

Exam at a glance

PCAP-31-04 practice exam settings
Practice tests 5
Questions in total 290
Questions per test About 62
Time limit per test 90 minutes
Pass mark 72%
Question types Single answer and multiple answer (26 multiple-answer questions)
Level Associate
Category Programming

These are the settings of our practice tests. Check the official Python Institute exam page for the current exam format before you book.

Domains and weights

PCAP-31-04 exam domains, weights and question counts
Domain Weight Weight bar Questions in our bank
Modules and Packages 12% 35
Exceptions 12% 35
Strings 10% 29
Object-Oriented Programming 28% 81
Advanced Python Constructs and I/O 24% 69
Testing, Debugging, Collaborative Development, and AI Assistance 14% 41

Sample questions

Question 1 of 3, choose 2

A team wants reproducible environments for a Python service. Which two pip practices directly support this goal? (Choose two.)

  1. A Use 'pip show' on the build server to decide which versions to install at deploy time
  2. B Run 'pip install --upgrade' on every package before each deployment to stay current
  3. C Recreate the environment elsewhere with 'pip install -r requirements.txt' (correct answer)
  4. D Generate a pinned list with 'pip freeze > requirements.txt' and commit it with the code (correct answer)
  5. E Install packages globally with 'pip install --user' so that every project shares them
Why: pip freeze writes the exact installed versions in requirement-specifier form, and installing from that file with -r rebuilds the same set of versions on another machine. Upgrading everything before each deployment pulls whatever is newest and breaks reproducibility, a shared --user install mixes dependencies between projects, and pip show only displays metadata for an installed package rather than defining what should be installed.

Question 2 of 3, choose 2

A developer defines a custom exception for an inventory module. Which two practices are recommended? (Choose two.)

  1. A Name the class without the Error suffix so it cannot be confused with built-in exception classes
  2. B Derive the class from Exception or from a more specific built-in exception rather than from BaseException (correct answer)
  3. C Raise the class itself with a string, as in 'raise InventoryError, "low stock"', to attach a message
  4. D Group related errors under a common base class, such as InventoryError, so callers can catch them together (correct answer)
  5. E Derive the class from BaseException so that a bare 'except Exception' clause cannot intercept it
Why: Application exceptions should inherit from Exception (or a specific built-in subclass) and are commonly organised under a shared base class so callers can handle the whole family. Deriving from BaseException puts the class alongside SystemExit and KeyboardInterrupt and makes it escape normal handlers, which is not the intent. The Error suffix is the standard naming convention, and the comma raise syntax is Python 2 and a SyntaxError in Python 3.

Question 3 of 3

A path-cleaning helper strips characters from the ends of a string: a = '//report.txt/'.strip('/') b = 'data/report.txt'.rstrip('.txt') print(a + '|' + b) What is printed?

  1. A report.txt|data/report
  2. B report.txt|data/repor (correct answer)
  3. C report|data/report
  4. D report.txt|data/report.txt
Why: strip() and its variants treat the argument as a set of characters, not as a substring. strip('/') removes slashes from both ends of the first string. rstrip('.txt') keeps removing trailing characters while they are '.', 't' or 'x', so after '.txt' it also removes the final 't' of 'report' and stops at 'r', leaving 'data/repor'. To remove an exact suffix, use removesuffix('.txt').

What your score report looks like

Example attempt, PCAP-31-04 practice test 3

74%

Passed
Pass mark 72%

Score by exam domain
DomainWeightYour score%
Modules and Packages 12%
88
Exceptions 12%
81
Strings 10%
76
Object-Oriented Programming 28%
58
Advanced Python Constructs and I/O 24%
84
Testing, Debugging, Collaborative Development, and AI Assistance 14%
72

Study next: Object-Oriented Programming. It is below the pass mark and carries 28% of the exam.

Domains and pass mark from our PCAP-31-04 practice tests. Scores are an example attempt.

Study plans

Two weeks

  1. Day 1: take practice test 1 in exam mode to get a baseline.
  2. Days 2 to 5: domain mode on Object-Oriented Programming and Advanced Python Constructs and I/O, the two most heavily weighted domains.
  3. Day 6: practice test 2 in exam mode, then the mistakes quiz.
  4. Days 7 to 12: practice tests 3 to 5, one every other day, each followed by its mistakes quiz.
  5. Days 13 and 14: final mode. Book the exam when your readiness stays above the pass mark.

Four weeks

  1. Week 1: one practice test in practice mode, reading every explanation. Note your two lowest domains.
  2. Week 2: domain mode on those two domains, then a second practice test in exam mode.
  3. Week 3: practice tests 3 and 4 in exam mode, with the mistakes and flagged quizzes after each.
  4. Week 4: practice test 5 and final mode until your readiness holds above the pass mark.

Questions about the PCAP-31-04 practice exams

Are these real PCAP-31-04 exam questions?
No. We write every question ourselves and map it to the published PCAP-31-04 exam objectives. We do not use leaked or recalled questions.
Do the time limit and pass mark match the official exam?
They match the settings of our practice tests. Exam providers change their format from time to time, so check the official exam page before you book.
Can I try it before I pay?
Yes. The free mini exam has 15 questions with full explanations and needs no account.
How long do I keep access?
A single-exam purchase gives you 12 months of access. All-Access includes this exam for as long as your subscription runs.
What happens after I finish a test?
You get a score, a pass or fail against the pass mark, a score per domain and every answer with its explanation.

Last updated November 2026. Written and reviewed by the DevOpsCode Lab team.

DevOpsCode Lab is not affiliated with Python Institute. PCAP-31-04 and related names are trademarks of their owners.

Related exams
Exam Vendor Level Questions Minutes Price
PCPP-32-101PCPP1 PCPP-32-101 Python Institute Professional 225 65 $14.99
PCEP-30-03PCEP - Entry-Level Python Programmer (PCEP-30-03) Python Institute Foundational 200 55 $9.99
1Z0-830Java 21 Developer 1Z0-830 Oracle Associate 250 120 $12.99