Skip to content

PCAP Practice Questions

Prepare for PCAP with more than an answer.

316 questions in the full set20 sample questionsUpdated Sep 16, 2021
Exam fee
$295 USD
Level
Associate
Valid for
lifetime
Domains covered on the exam 5
  1. Modules and Packages12%
  2. Exceptions14%
  3. Strings18%
  4. Object-Oriented Programming34%
  5. Miscellaneous22%
  1. 1

    If any of a class’s components has a name that starts with two underscores (___), then:

    Show answer details
  2. 2

    How many elements will the listl list contain after execution of the following snippet?

    Question exhibit
    Show answer details

    Correct answer: A

    A

  3. 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?

    Question exhibit
    Show answer details

    Correct answer: A

    A

  4. 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
  5. 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 <|-- D
    Show 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. 6

    What is the expected behavior of the following code?

    It will:

    Question exhibit
    Show answer details

    Correct answer: B

    B

  7. 7

    Which of the equations are True? (Select two answers)

    Show answer details

    Correct answer: A, D

    A, D

    A, D

  8. 8

    What will the value of the i variable be when the following loop finishes its execution?

    Question exhibit
    Show answer details
  9. 9

    Which of the listed actions can be applied to the following tuple? (Select two answers)

    Question exhibit
    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. 10

    Files with the suffix .pyc contain:

    Show answer details

    Correct answer: D

    D

Create an account to continue.