ExamDumpster

Free PCAP sample questions

Check your Python with these free PCAP sample questions, each with the answer and an explanation. They cover classes and inheritance, exception handling and closures. Read each explanation to see why the code behaves as it does.

Try them in the simulator Same questions, with study, timed and flashcard modes.

Showing 10 of 20 free sample questions.

Question 1Choose one

A two-parameter lambda function raising its first parameter to the power of the second parameter should be declared as:

Question 2Choose one

The following class hierarchy is given. What is the expected out of the code?

Question 3Choose 2

If you need a function that does nothing, what would you use instead of XXX? (Select two answers)

Question 4Choose one

Is it possible to safely check if a class/object has a certain attribute?

Question 5Choose one

The following expression is:

Question 6Choose one

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

Question 7Choose one

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

Question 8Choose one

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 9Choose 2

You are going to read 16 bytes from a binary file into a bytearray called data. Which lines would you use? (Select two answers)

Question 10Choose one

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? ```python 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

10 more free samples are waiting

Create a free account to unlock the whole PCAP sample bank, or get full access to all 316 practice questions in the simulator.

Create account