Skip to content
Zurück zu den Lernmaterialien

50 Free PCAP Practice Questions — Python Certified Associate Programmer

29. Juli 2026~2 min read

Preparing for PCAP? These questions cover advanced Python concepts.


OOP (Questions 1–15)

Question 1

What is the output of this code?

class A:
    def __init__(self, x):
        self.x = x

    def __str__(self):
        return f"A({self.x})"

obj = A(5)
print(obj)

a) <__main__.A object at 0x...>
b) A(5)
c) 5
d) Error

Show Answer

Answer: b) A(5)

Explanation: The __str__ method defines the string representation of an object. print() calls str(), which calls __str__. Without it, the default object representation is shown.

Question 2

Which keyword is used to refer to the parent class in Python?

a) parent
b) super
c) super()
d) base

Show Answer

Answer: c) super()

Explanation: super() returns a proxy object that delegates method calls to the parent class. It's used for calling parent class methods, especially __init__.

Questions 3–15

[Full OOP set covers inheritance, polymorphism, encapsulation, property decorators, class/static methods, magic methods]


Functions and Generators (Questions 16–25)

Question 3

What is the output of this generator?

def gen():
    yield 1
    yield 2
    yield 3

g = gen()
print(next(g))
print(next(g))

a) 1 2
b) 1 1
c) 2 3
d) Error

Show Answer

Answer: a) 1 2

Explanation: Generators produce values lazily using yield. Each call to next() resumes execution until the next yield. The generator state is preserved between calls.

Questions 4–25

[Full set covers lambda, map/filter/reduce, args/kwargs, closures, decorators, list comprehensions]


Data Aggregations and Strings (Questions 26–35)

Question 4

Which collection type counts hashable objects?

a) defaultdict
b) Counter
c) OrderedDict
d) namedtuple

Show Answer

Answer: b) Counter

Explanation: collections.Counter counts hashable objects. Counter('abracadabra') returns {'a': 5, 'b': 2, 'r': 2, 'c': 1, 'd': 1}.

Questions 5–35

[Full set covers collections module, string methods, slicing, formatting, regex basics]


Modules and Exceptions (Questions 36–50)

Question 5

Which module provides system-specific parameters and functions?

a) system
b) os
c) sys
d) platform

Show Answer

Answer: c) sys

Explanation: sys provides system-specific parameters (sys.argv, sys.path, sys.exit(), sys.version). os provides OS interfaces (files, processes, environment).

Questions 6–50

[Full set covers exception hierarchy, custom exceptions, module imports, packages, pip]


How Did You Score?

Access all PCAP practice questions →

Bereit, dein Wissen zu testen?

Probiere unsere Übungsprüfungen mit Hunderten von realistischen Fragen aus.

Üben starten →

This site uses essential cookies for Stripe payments. No tracking cookies.