PCAP Certified Associate in Python Programming Exam Questions, Exams of Technology

A set of questions and answers designed to help individuals prepare for the pcap (certified associate in python programming) certification exam. The questions cover various aspects of python programming, including module imports, sys.path, random module functions, math module functions, built-in functions, package directories, and exception handling. Each question is followed by the correct answer and a brief explanation to enhance understanding and test preparation. This resource is valuable for students and professionals aiming to validate their python skills and knowledge.

Typology: Exams

2024/2025

Available from 10/24/2025

anil-kumar-jain-1
anil-kumar-jain-1 🇮🇳

2.9

(15)

27K documents

1 / 185

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PCAP 31 03PCAP Certified Associate
in Python Programming IntelCloud
Solutions Architect Exam
Question 1. Which of the following statements correctly imports only
the sqrt function from the math module?
A) import math.sqrt
B) from math import sqrt
C) import sqrt from math
D) from math import *
Answer: B
Explanation: The syntax from math import sqrt imports only the sqrt
function from the math module.
Question 2. What does the sys.path variable contain?
A) All built-in Python functions
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download PCAP Certified Associate in Python Programming Exam Questions and more Exams Technology in PDF only on Docsity!

in Python Programming IntelCloud

Solutions Architect Exam

Question 1. Which of the following statements correctly imports only the sqrt function from the math module? A) import math.sqrt B) from math import sqrt C) import sqrt from math D) from math import * Answer: B Explanation: The syntax from math import sqrt imports only the sqrt function from the math module. Question 2. What does the sys.path variable contain? A) All built-in Python functions

in Python Programming IntelCloud

Solutions Architect Exam

B) List of directories Python searches for modules C) Current working directory D) List of all loaded modules Answer: B Explanation: sys.path is a list of strings indicating the search path for modules. Question 3. Which function in the random module returns a random element from a non-empty sequence? A) random() B) choice() C) sample()

in Python Programming IntelCloud

Solutions Architect Exam

Question 5. Which built-in function can be used to see all attributes of an imported module? A) list() B) dir() C) help() D) attributes() Answer: B Explanation: dir() lists all attributes and methods of an object or module.

in Python Programming IntelCloud

Solutions Architect Exam

Question 6. What is the purpose of the init.py file in a package directory? A) It is required to mark a directory as a Python package B) It stores initialization variables C) It is always empty D) It prevents importing modules Answer: A Explanation: init.py is needed to mark directories on disk as Python package directories. Question 7. Which statement about the pycache directory is true? A) It stores compiled bytecode of imported modules

in Python Programming IntelCloud

Solutions Architect Exam

Answer: D Explanation: When a script runs directly, name is set to 'main'. Question 9. How can you import a function from a nested module within a package? A) from package.module import function B) import module.function C) from module import package.function D) from package import function Answer: A Explanation: The correct way is from package.module import function.

in Python Programming IntelCloud

Solutions Architect Exam

Question 10. Which math module function returns the largest integer less than or equal to a number? A) ceil() B) floor() C) trunc() D) round() Answer: B Explanation: floor() returns the largest integer less than or equal to the input. Question 11. Which random module function can be used to get a list of unique random elements from a sequence?

in Python Programming IntelCloud

Solutions Architect Exam

D) The processor type Answer: A Explanation: platform.system() returns the name of the OS, such as 'Windows', 'Linux'. Question 13. Which of these will import and alias the random module as rnd? A) import random as rnd B) from random import rnd C) import rnd from random D) from random import random as rnd Answer: A

in Python Programming IntelCloud

Solutions Architect Exam

Explanation: import random as rnd renames the random module to rnd within the script. Question 14. What is the purpose of the dir() function when used on a module? A) Lists all modules B) Lists all attributes and functions C) Returns documentation D) Imports all functions Answer: B Explanation: dir(module) returns a list of names defined in the module.

in Python Programming IntelCloud

Solutions Architect Exam

B) sys.path C) search.path D) import.path Answer: B Explanation: sys.path is the list Python uses to find modules. Question 17. What does the math.trunc(3.9) function return? A) 4 B) 3 C) 3. D) 0

in Python Programming IntelCloud

Solutions Architect Exam

Answer: B Explanation: math.trunc() truncates the decimal part, returning just the integer. Question 18. Which random module function should you use to initialize the random number generator for reproducibility? A) random() B) seed() C) shuffle() D) sample() Answer: B Explanation: random.seed() initializes the random number generator.

in Python Programming IntelCloud

Solutions Architect Exam

A) A Python file with functions/class definitions B) A directory with init.py only C) A compiled C file D) A text file with no code Answer: A Explanation: A module is a Python file with code (functions, classes, etc.). Question 21. What is the convention for naming private variables in a module? A) Start with __ B) Start with _

in Python Programming IntelCloud

Solutions Architect Exam

C) End with __ D) Start with priv_ Answer: B Explanation: Variables starting with a single underscore (_) are considered private. Question 22. In a package, what is the effect of omitting init.py in a directory? A) Directory can't be imported as a package B) No effect C) Directory is deleted D) Only submodules can be imported

in Python Programming IntelCloud

Solutions Architect Exam

Question 24. How does Python search for modules when importing? A) In the current directory first, then sys.path B) Only in the standard library C) Only in user directories D) In pycache only Answer: A Explanation: Python searches the current directory, then the paths in sys.path. Question 25. What does except (ValueError, TypeError) do? A) Catches both ValueError and TypeError exceptions

in Python Programming IntelCloud

Solutions Architect Exam

B) Catches only TypeError C) Ignores both exceptions D) Raises ValueError Answer: A Explanation: The syntax catches either of the listed exceptions. Question 26. What happens if an exception isn't caught in Python? A) Program continues B) Program crashes and prints a traceback C) Exception is ignored D) Next exception is raised