↓ Try a sample question (with explanation)

Python Institute · Practice questions

PCAP - Certified Associate in Python Programming

Study 139 PCAP - Certified Associate in Python Programming practice questions with explanations. 20 of them are free to try, no sign-up needed.

Buy to unlock all questions, full reading mode and PDFs.

About this question bank

Questions
139 in total
Free to try
20 questions (no sign-up)
Exam domains
5 domains
Price
JPY 1,500 (≈ US$10; shown in your local currency at checkout) · one-time payment · 3 months
PDF
Japanese–English · Chinese–English · Korean–English · English (for buyers)
Data version
2026-12

About this exam

An associate-level certification from the Python Institute for Python programmers. Going a step beyond PCEP, it covers modules and packages, strings, exception handling, and object-oriented programming (classes, inheritance, instance and class variables).

Try a sample question

This is an original sample question written by itmoshi based on the exam objectives.

Shared helpers live in a module, tools.py, which main.py uses (see the exhibit). When you run python main.py in the same directory, which lines are printed, in order (/ marks a line break)?

Exhibit
# tools.py
print("loading tools")

def helper():
    return "help"

if __name__ == "__main__":
    print("tools run directly")

# main.py
import tools
import tools
from tools import helper
print(__name__, tools.__name__, helper())
  1. Aloading tools / loading tools / __main__ tools help
  2. Bloading tools / tools run directly / __main__ tools help
  3. Cloading tools / tools __main__ help
  4. Dloading tools / __main__ tools help
Show answer and explanation

Answer:D It prints two lines: loading tools / __main__ tools help.

Why it is correct

On the first import, Python creates the module, puts it in sys.modules, and then executes its top-level code. The second import tools and the from tools import helper just reuse that module, so loading tools is printed once. An imported module's __name__ is its module name, "tools", so the if __name__ == "__main__": block does not run. main.py, run directly, has __name__ set to "__main__", so the last line is __main__ tools help.

The other options

  • ✗ A This assumes each import re-executes the module. Later imports simply return the module already in sys.modules; use importlib.reload if you really need to run it again.
  • ✗ B This assumes the __main__ block runs in an imported module. It runs only when tools.py itself is executed directly, as in python tools.py.
  • ✗ C This swaps the two __name__ values. The script run directly is "__main__"; an imported module gets its module name.

Key takeaway

import → runs only the first time (later imports reuse sys.modules; re-run with importlib.reload). __name__ → "__main__" when run directly, the module name when imported.

Try 20 questions like this for free

Most frequent topics

  1. Python syntax and semantics22 questions
  2. Defining classes and objects20 questions
  3. Data types, variables, and basic I/O16 questions
  4. Strings and string operations13 questions
  5. Defining and calling functions10 questions
  6. Importing modules and packages9 questions

Number of questions per topic among the 139 in this bank (top topics), as classified by itmoshi.

Exam domains

  1. Basic Concepts58 questions
  2. Data Structures11 questions
  3. Functions and Modules26 questions
  4. Object-Oriented Programming35 questions
  5. File Input/Output and Streams9 questions

Other Python Institute exams

← All exams

itmoshi is an unofficial study service and is not affiliated with Python Institute or any exam provider.