Certified Associate in Python Programming

Here you have the best Python Institute PCAP-31-03 practice exam questions

  • You have 129 total questions across 26 pages (5 per page)
  • These questions were last updated on February 13, 2026
  • This site is not affiliated with or endorsed by Python Institute.
Question 1 of 129

What is true about Python packages? (Choose two.)
Answer

Suggested Answer

The suggested answer is C, D.

A package in Python may contain an __init__.py file which is intended to initialize the package's state; however, the correct name for this file is __init__.py, not init.py. The __pycache__ folder is used to store semi-compiled (bytecode) Python modules, which are generated when the Python interpreter executes scripts for better performance. The sys.path variable is indeed a list of strings that specifies the directories the interpreter should search for modules being imported. Therefore, the correct statements are that __pycache__ is a folder that stores semi-compiled Python modules and that the sys.path variable is a list of strings.

Community Votes5 votes
CDSuggested
80%
AC
20%
Question 2 of 129

What is the expected output of the following code?
import sys
import math
b1 = type(dir(math)) is list
b2 = type(sys.path) is list
print(b1 and b2)
Answer

Suggested Answer

The suggested answer is B.

In the given code, 'b1 = type(dir(math)) is list' checks if the return type of 'dir(math)' is a list, which it is. Similarly, 'b2 = type(sys.path) is list' checks if 'sys.path' is a list, which is also true. Since both b1 and b2 are true, 'print(b1 and b2)' will output True.

Community Votes9 votes
BSuggested
100%
Question 3 of 129

A Python package named pypack includes a module named pymod.py which contains a function named pyfun().
Which of the following snippets will let you invoke the function? (Choose two.)
Answer

Suggested Answer

The suggested answer is A, D.

To invoke the function pyfun() from the module pymod inside the package pypack, there are two correct approaches. The first approach is to directly import the function using 'from pypack.pymod import pyfun', which allows you to call pyfun() directly. The second approach is to import the package and the module separately using 'import pypack' and 'import pypack.pymod', then you can call the function using 'pypack.pymod.pyfun()'.

Community Votes3 votes
ADSuggested
100%
Question 4 of 129

Assuming that the code below has been executed successfully, which of the following expressions will always evaluate to True? (Choose two.) import random v1 = random.random() v2 = random.random()
Answer

Suggested Answer

The suggested answer is C.

The expressions that will always evaluate to True involve understanding the behavior of the functions used. The function random.random() generates a float number between 0.0 and 1.0, so v1 and v2 will never be equal and v1 will never be greater than 1. Therefore, the expression 'v1 == v2' will always evaluate to False. Similarly, 'v1 > 1' will always evaluate to False. The function random.sample([1,2,3], 1) generates a list of one element sampled from the given list, making 'len(random.sample([1,2,3],1)) > 2' impossible as the length will always be 1. The only expression that will always be True is 'random.choice([1,2,3]) > 0' because random.choice([1,2,3]) will always choose a number from the list [1, 2, 3], all of which are greater than 0.

Community Votes2 votes
CSuggested
100%
Question 5 of 129

With regards to the directory structure below, select the proper forms of the directives in order to import module_c. (Choose two.)
Exam PCAP-31-03: Question 5 - Image 1
Answer

Suggested Answer

The suggested answer is A, B.

The correct forms of the directives to import module_c file considering the directory structure are: 'from pypack.upper.lower import module_c' and 'import pypack.upper.lower.module_c'. These correctly reference the full path of the module. The other options are incorrect because they either omit necessary parts of the path or do not start from the root package.

Community Votes9 votes
ABSuggested
100%

About the Python Institute PCAP-31-03 Certification Exam

About the Exam

The Python Institute PCAP-31-03 (Certified Associate in Python Programming) validates your knowledge and skills. Passing demonstrates proficiency and can boost your career prospects in the field.

How to Prepare

Work through all 129 practice questions across 26 pages. Focus on understanding the reasoning behind each answer rather than memorizing responses to be ready for any variation on the real exam.

Why Practice Exams?

Practice exams help you familiarize yourself with the question format, manage your time, and reduce anxiety on the test day. Our PCAP-31-03 questions are regularly updated to reflect the latest exam objectives.