PCAP Practice Questions
Prepare for PCAP with more than an answer.
- Exam fee
- $295 USD
- Level
- Associate
- Valid for
- lifetime
Domains covered on the exam 5
- Modules and Packages12%
- Exceptions14%
- Strings18%
- Object-Oriented Programming34%
- Miscellaneous22%
- 1
If any of a class’s components has a name that starts with two underscores (___), then:
Show answer details
Correct answer: A
- 2
How many elements will the listl list contain after execution of the following snippet?

Show answer details
Correct answer: A
A
- 3
The following class definition is given. We want the show () method to invoke the get () method, and then output the value the get () method returns. Which of the invocations should be used instead of XXX?

Show answer details
Correct answer: A
A
- 4
You are going to read 16 bytes from a binary file into a bytearray called data. Which lines would you use? (Select two answers)
Show answer details
Correct answer: C, D
C, D -- Reference: https://www.devdungeon.com/content/working-binary-data-python
C, D -- Reference: https://www.devdungeon.com/content/working-binary-data-python
- 5
A developer has implemented a class hierarchy with multiple inheritance that exhibits the 'diamond problem'. They want to understand how Python's Method Resolution Order (MRO) will resolve a method call. Given the following code, what is the printed output?
class A: def ping(self): print('A') class B(A): def ping(self): print('B') super().ping() class C(A): def ping(self): print('C') super().ping() class D(B, C): def ping(self): print('D') super().ping() d = D() d.ping()classDiagram class A { +ping() } class B { +ping() } class C { +ping() } class D { +ping() } A <|-- B A <|-- C B <|-- D C <|-- DShow answer details
Correct answer: B
This is correct. Python uses the C3 linearization algorithm for its Method Resolution Order (MRO). For class D, the MRO is D -> B -> C -> A -> object. The
super().ping()call in each method follows this chain: D calls B, B calls C, C calls A. This ensures that each parent class method in the hierarchy is called exactly once. - 6
What is the expected behavior of the following code?
It will:

Show answer details
Correct answer: B
B
- 7
Which of the equations are True? (Select two answers)
Show answer details
Correct answer: A, D
A, D
A, D
- 8
What will the value of the i variable be when the following loop finishes its execution?

Show answer details
Correct answer: B
- 9
Which of the listed actions can be applied to the following tuple? (Select two answers)

Show answer details
Correct answer: C, D
C, D -- Reference: https://www.tutorialspoint.com/python/python tuples.htm
C, D -- Reference: https://www.tutorialspoint.com/python/python tuples.htm
- 10
Files with the suffix .pyc contain:
Show answer details
Correct answer: D
D
