What the PCAP exam covers
- Modules and Packages106 questions
- Exceptions119 questions
- Strings153 questions
- Object-Oriented Programming238 questions
- Miscellaneous187 questions
Free PCAP sample questions
A sample of 10 questions with answers and explanations. Sign up free to practice all 803.
-
Which import statement makes the name sqrt usable WITHOUT any module prefix, so that sqrt(9) works directly?
- Afrom math import sqrtCorrect
- Bimport math
- Cimport math.sqrt
- Dimport sqrt from math
✓ Correct answer: AThe from-import form 'from math import sqrt' binds sqrt directly in the current namespace, so you call it as sqrt(9) with no prefix.
Why the other options are wrong- Bimport math binds only the name math, so you would have to write math.sqrt(9).
- Cimport math.sqrt is invalid because sqrt is a function, not an importable submodule of math.
- D'import sqrt from math' is not valid Python; the correct order is 'from math import sqrt'.
-
You created two files in the same directory: helper.py (defining triple(x)) and main.py. Which content in main.py correctly uses triple?
- Aimport helper print(helper.triple(3))Correct
- Bimport helper.triple print(triple(3))
- Cfrom helper print(triple(3))
- Dinclude helper print(helper.triple(3))
✓ Correct answer: ABecause helper.py sits alongside main.py, 'import helper' finds it via the script directory on sys.path, and the function is called as helper.triple.
Why the other options are wrong- B'import helper.triple' treats triple as a submodule; triple is a function, so this fails.
- C'from helper' is incomplete syntax; it needs 'from helper import triple'.
- DPython has no 'include' statement; modules are brought in with import.
-
What is the output? def f(): try: raise ValueError('x') finally: return 99 print(f())
- A99Correct
- BValueError
- Cx
- DNone
✓ Correct answer: AA return inside finally swallows the propagating exception and returns instead, so the ValueError is discarded and f() returns 99.
Why the other options are wrong- BThe return in finally suppresses the ValueError, so nothing propagates.
- CThe exception is swallowed by the finally return; its message is never seen.
- Dfinally explicitly returns 99, not None.
-
Which TWO of the following expressions evaluate to True? (Select TWO.)
- A"HELLO".isupper()Correct
- B"Hello".isupper()
- C"A Nice Day".istitle()Correct
- D"A Nice DAY".istitle()
✓ Correct answer: A, Cisupper() is True when all cased characters are uppercase, which holds for "HELLO". istitle() is True when every word starts with an uppercase letter and the rest are lowercase, which holds for "A Nice Day".
Why the other options are wrong- B"Hello" contains the lowercase letters ello, so isupper() returns False.
- D"DAY" is fully uppercase rather than titlecased, so istitle() returns False.
-
What is the output of the following code? print(len('hello'))
- A5Correct
- B4
- C6
- Dhello
✓ Correct answer: Alen() returns the number of characters in the string. 'hello' contains h, e, l, l, o, which is 5 characters.
Why the other options are wrong- B4 undercounts; both 'l' characters are counted, giving 5.
- C6 overcounts; there is no trailing character beyond the five letters.
- Dlen returns an integer count, not the string itself.
-
Is a dunder name such as __dict__ subject to name mangling inside a class body?
- AYes, every identifier that begins with two underscores is mangled inside a class.
- BYes, __dict__ is rewritten to _ClassName__dict__ within the class.
- CNo, names with two trailing underscores are excluded from mangling.Correct
- DNo, mangling is applied only to names that have no leading underscores.
✓ Correct answer: CName mangling applies only to identifiers of the form __name with at most one trailing underscore. A name like __dict__ has two trailing underscores, so it is left unchanged. This lets special attributes keep their intended names.
Why the other options are wrong- ATrailing double underscores exempt a name from mangling.
- B__dict__ is not rewritten; it keeps its name.
- DMangling targets leading double underscores, not their absence.
-
What is the output of the following code? class A: def __init__(self): super().__init__() self.x = 5 print(A().x)
- A5Correct
- BTypeError
- CAttributeError
- DNone
✓ Correct answer: AEven with no explicit base, A implicitly inherits from object, so super().__init__() harmlessly calls object.__init__(). Then self.x is set to 5.
Why the other options are wrong- Bobject.__init__() accepts the call with no extra arguments, so no TypeError occurs.
- Cself.x is assigned 5, so reading A().x finds it and no AttributeError occurs.
- Dx is explicitly set to 5, not None.
-
What is the output of the following code? class A: def __eq__(self, other): return NotImplemented print(A() == A())
- AFalseCorrect
- BTrue
- CNotImplemented
- DA TypeError is raised
✓ Correct answer: AWhen both the direct and reflected __eq__ return NotImplemented, Python falls back to identity comparison. Two distinct objects are not identical, so == yields False.
Why the other options are wrong- BThe identity fallback compares different objects, giving False, not True.
- CNotImplemented is an internal signal; the final result of == is the boolean False.
- DReturning NotImplemented triggers a fallback rather than an error for ==.
-
What is the output of the following code? def bank(balance): def deposit(amount): nonlocal balance balance += amount return balance return deposit acct = bank(100) acct(50) print(acct(25))
- A175Correct
- B125
- C75
- D100
✓ Correct answer: AThe closure captures balance via nonlocal, so state persists across calls. Starting at 100, acct(50) makes it 150, then acct(25) makes it 175.
Why the other options are wrong- BThis ignores the first deposit; balance accumulates across both calls.
- CThe deposits are added, not subtracted, so the balance grows above the starting value.
- DDeposits change the captured balance, so it does not stay at 100.
-
What does time.localtime() return?
- AA struct_timeCorrect
- BA float of seconds since the epoch
- CA datetime.datetime object
- DA tuple of strings
✓ Correct answer: Atime.localtime converts a seconds-since-epoch value (or the current time if omitted) into a time.struct_time expressed in local time.
Why the other options are wrong- BA float of seconds comes from time.time(); localtime converts such a value into a struct_time.
- Clocaltime belongs to the time module and returns a struct_time, not a datetime object.
- Dstruct_time holds integers accessible by index and by name; it is not a tuple of strings.
Related Python resources
- PCAP study guideKey concepts
- Python practice examsAll Python
- Certification pathWhere this fits
- Certification exam guides & tipsBlog
- Plans & pricingFree & paid
- PCEP practice examRelated
- Python Automation for IT practice examRelated
PCAP practice exam FAQ
How many questions are in the PCAP practice exam on CertGrid?
CertGrid has 803 practice questions for PCAP: Certified Associate Python Programmer, covering 5 exam domains. The real PCAP exam is 40 qs in 65 min. CertGrid's timed mock is a fixed 40 questions.
What is the passing score for PCAP?
The PCAP exam passing score is 70%, and you have about 65 min to complete it. CertGrid scores your practice attempts the same way so you know when you are ready.
Are these official PCAP exam questions?
No. CertGrid is an independent practice platform. We do not provide real or leaked exam questions. Our questions are original and designed to help you practice the concepts, scenarios, and difficulty style of the PCAP: Certified Associate Python Programmer exam.
Can I practice PCAP for free?
Yes. You can start practicing PCAP: Certified Associate Python Programmer for free with daily practice and sample questions. Paid plans unlock full timed exams, complete explanations, and domain analytics.
What CertGrid is (and is not)
CertGrid is an independent IT certification practice platform for Azure, AWS, Google, Cisco, Security, Linux, Kubernetes, Terraform, and other certification tracks. It provides objective-mapped practice questions, readiness scoring, weak-domain drills, and explanations to help learners understand what to study next.
Independent & original. CertGrid is an independent practice platform and is not affiliated with or endorsed by Python. Questions are original practice items designed to mirror certification concepts and exam style. CertGrid does not provide official exam questions or braindumps.