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

> 5 timed PCAP-31-04 practice tests with 290 questions and a 72% pass mark. See your score in Object-Oriented Programming and every other domain.

Page: https://devopscodelab.com/exams/pcap-python-associate/

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

| Setting | Value |
| --- | --- |
| 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 format before you book.

## Domains and weights

| Domain | Weight | 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 |

## Price and access

- PCAP-31-04 practice exams: $12.99 for 12 months of access.
- Free mini exam: 15 questions with explanations (free account): https://devopscodelab.com/app/exams/pcap-python-associate/mini/
- All-Access subscription includes every exam: https://devopscodelab.com/pricing/
- 10 free questions with answers: https://devopscodelab.com/exams/pcap-python-associate/free-practice-questions/

## 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.)

- A. Use 'pip show' on the build server to decide which versions to install at deploy time
- B. Run 'pip install --upgrade' on every package before each deployment to stay current
- C. Recreate the environment elsewhere with 'pip install -r requirements.txt'
- D. Generate a pinned list with 'pip freeze > requirements.txt' and commit it with the code
- E. Install packages globally with 'pip install --user' so that every project shares them

**Answer:** C, D

**Explanation:** 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.)

- A. Name the class without the Error suffix so it cannot be confused with built-in exception classes
- B. Derive the class from Exception or from a more specific built-in exception rather than from BaseException
- C. Raise the class itself with a string, as in 'raise InventoryError, "low stock"', to attach a message
- D. Group related errors under a common base class, such as InventoryError, so callers can catch them together
- E. Derive the class from BaseException so that a bare 'except Exception' clause cannot intercept it

**Answer:** B, D

**Explanation:** 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?

- A. report.txt|data/report
- B. report.txt|data/repor
- C. report|data/report
- D. report.txt|data/report.txt

**Answer:** B

**Explanation:** 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').


## 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.

DevOpsCode Lab is not affiliated with Python Institute. PCAP-31-04 and related names are trademarks of their owners. We write every question ourselves; these are not real exam questions.
