Back to Certified Associate Python Programmer PCAP questions

Scenario-based practice

Refer to the Exhibit Practice Questions

Practise Certified Associate Python Programmer PCAP practice questions — original exam-style scenarios covering every exam domain, with detailed explanations, wrong-answer analysis, and common exam traps.

15
scenario questions
PCAP
exam code
Python Institute
vendor

Scenario guide

How to approach refer to the exhibit practice questions

Practise exhibit-style questions that ask you to read a topology, table, command output or diagram before choosing the best answer.

Quick answer

Exhibit-style questions test whether you can read a topology, command output, diagram or table before choosing the best answer.

How to extract the relevant detail from an exhibit.

How topology, command output or routing information affects the answer.

How to avoid answering from memory before reading the evidence.

How to map the exhibit back to the exam objective.

Related practice questions

Related PCAP topic practice pages

Scenario questions usually connect to one or more exam topics. Use these links to review the underlying concepts behind the scenario.

Practice set

Practice scenarios

Question 1mediummultiple choice
Full question →

Refer to the exhibit. What is the output of the code?

Exhibit

s = 'Python Programming'
print(s[7:])
Question 2hardmultiple choice
Full question →

Refer to the exhibit. What is the output?

Exhibit

class Counter:
    count = 0
    def __init__(self):
        Counter.count += 1
        self.id = Counter.count

c1 = Counter()
c2 = Counter()
print(c1.id, c2.id)
Question 3hardmultiple choice
Full question →

Refer to the exhibit. What does the 'from None' clause do in the second raise statement?

Exhibit

Traceback (most recent call last):
  File "app.py", line 10, in <module>
    raise ValueError('Invalid value')
ValueError: Invalid value

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "app.py", line 12, in <module>
    raise TypeError('Type mismatch') from None
TypeError: Type mismatch
Question 4easymultiple choice
Full question →

Given the exhibit, why does `dir()` show no names from `mypackage` after executing `from mypackage import *`?

Exhibit

Refer to the exhibit.

```
# file: mypackage/__init__.py
from . import module1
from .module2 import func2
__all__ = ['module1', 'func2']
```

```
# file: mypackage/module2.py
def func2():
    print('func2')
```

```python
>>> from mypackage import *
>>> dir()
['__builtins__', ...]
```
Question 5hardmulti select
Full question →

Refer to the exhibit. Which THREE statements about the class hierarchy are correct?

Exhibit

class A:
    def method(self):
        return 'A'

class B(A):
    def method(self):
        return 'B'

class C(A):
    def method(self):
        return 'C'

class D(B, C):
    pass
Question 6hardmultiple choice
Full question →

Refer to the exhibit. What is the output?

Exhibit

text = 'Hello, World!'
result = text.replace('Hello', 'Hi').upper()
print(result)
Question 7mediummultiple choice
Full question →

Refer to the exhibit. What is the output?

Exhibit

class MyClass:
    def __init__(self, value):
        self.__value = value
    def get_value(self):
        return self.__value

obj = MyClass(10)
print(obj.__value)
Question 8mediummultiple choice
Full question →

Refer to the exhibit. What is the output of the code?

Exhibit

with open('file.txt', 'r') as f:
    data = f.read()
    print(f.closed)
# Output: False
Question 9easymultiple choice
Full question →

Refer to the exhibit. If the file config.cfg exists but the user does not have read permission, what will be printed?

Exhibit

try:
    with open('config.cfg', 'r') as f:
        data = f.read()
except FileNotFoundError:
    print('File not found')
except PermissionError:
    print('Permission denied')
Question 10easymultiple choice
Full question →

Refer to the exhibit. The above log shows an unhandled exception that caused the program to crash. The developer wants to handle this exception and log the error without crashing. Which exception type should be caught in the main code to capture this specific error?

Exhibit

2025-04-01 10:23:45 ERROR root: Unhandled exception
Traceback (most recent call last):
  File "process.py", line 15, in <module>
    process_data()
  File "process.py", line 7, in process_data
    raise ValueError('Invalid value')
ValueError: Invalid value
Question 11hardmultiple choice
Full question →

Refer to the exhibit. What is the output?

Exhibit

class A:
    def method(self):
        print("A", end="")
class B(A):
    def method(self):
        print("B", end="")
        super().method()
class C(A):
    def method(self):
        print("C", end="")
        super().method()
class D(B, C):
    def method(self):
        print("D", end="")
        super().method()
obj = D()
obj.method()
Question 12hardmultiple choice
Full question →

Refer to the exhibit. What is the root cause of the error?

Exhibit

class MyClass:
    def __init__(self):
        self.name = "test"
obj = MyClass()
print(obj.age)
Question 13easymultiple choice
Full question →

Refer to the exhibit. Which statement correctly creates an instance of `Dog` and calls the `bark` method?

Exhibit

class Dog:
    def __init__(self, name):
        self.name = name
    def bark(self):
        return "Woof!"

Refer to the exhibit. A Python script uses re.split with a regex pattern. What is the output?

Exhibit

$ python -c "import re; print(re.split(r'\s+', 'one   two three'))"
Question 15mediummultiple choice
Full question →

Refer to the exhibit. What is printed?

Exhibit

name = "Alice"
age = 25
txt = f"{name:>10} is {age:03d} years old."
print(txt)

These PCAP practice questions are part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style PCAP questions with detailed explanations, topic-based practice, mock exams, readiness tracking, and study analytics.