Courseiva
Free · No account needed · No credit card

Certified Associate Python Programmer PCAP Practice Test

169 questions with instant explanations, domain breakdown, and wrong-answer analysis. Built for the real exam.

Instant feedback after each answer
Full explanations included
Domain score breakdown
Real exam: 65 min
Pass mark: 700%

Sample questions with explanations

This is exactly what you see during practice — question, options, and a full explanation after you answer.

Q1Modules and Packageseasy
Full explanation →

A Python script imports the module 'my_module'. The developer wants to ensure that when the script is run directly, it executes a specific function, but when imported as a module, that function is not executed. Which code snippet achieves this?

if __name__ == '__main__': run()Correct
if __name__ == '__main__': run()Correct
Cif os.environ.get('RUN_MAIN'): run()
Dif sys.argv[0] == 'my_module': run()

Both options A and B are correct because they are identical and represent the standard Python idiom `if __name__ == '__main__': run()`. When the script is run directly, Python sets `__name__` to `'__main__'`, triggering the function. When imported, `__name__` is the module name, …Read full explanation

Q2Modules and Packageshard
Full explanation →

A developer notices that a custom package 'mypackage' is not being found when importing, even though it is installed in the site-packages directory. The developer suspects a conflict with another package of the same name. Which command should the developer run to diagnose the location from which Python is importing the package?

Aprint(mypackage)
Bprint(__file__)
print(mypackage.__file__)Correct
Dimport os; print(os.getcwd())

`mypackage.__file__` returns the filesystem path from which the module was loaded, allowing the developer to see exactly which `mypackage` Python is using. This directly reveals if the wrong package (e.g., from a different location or a conflicting installation) is being imported…Read full explanation

Q3Modules and Packagesmedium
Full explanation →

Which TWO of the following are valid ways to import a module named 'math' and give it an alias 'm'?

Afrom math import * as m
import math as mCorrect
Cimport math m
Dimport math alias m

Only B. Option B uses the correct syntax `import math as m` to import the entire math module with alias m. Option A is invalid because the asterisk (*) cannot be combined with an alias in a `from ... import` statement. Option C is missing the `as` keyword. Option D uses `alias` w…Read full explanation

Untimed Practice

Answer at your own pace. Explanation and domain tag shown immediately after each answer.

Timed Practice

Countdown timer starts immediately. Results and domain scores shown at the end — just like the real exam.

Why practice here?

Full explanations on every question

Not just the right answer — you get exactly why each wrong option is wrong, so you learn the concept, not the answer.

Domain score breakdown

After each session see your score by exam domain so you know exactly where to focus study time.

100% free, forever

No subscription, no trial, no email wall. Start a session in under 10 seconds.

Exam-style questions

Scenario-based, precise wording, realistic distractors — written to match what you actually see on exam day.

← All PCAP questionsPCAP exam guideStudy guidePractice by domain