PCAP-31-03 Practice Test

PCAP-31-03 Practice Test practice questions, page 5 of 5, with answer review and explanations.

Question 21

Assuming that the code below has been executed successfully, which of the following expressions evaluate to True? (Choose two.)

  1. 'var' in Class.__dict__
  2. 'data' in Object.__dict
  3. len(Class.__dict__) == 1
  4. 'data' in Class.__dict__

Question 22

What is the expected behavior of the following code?

  1. it outputs 1
  2. it outputs 0
  3. it raises an exception
  4. it outputs 2

Question 23

Assuming that the code below has been placed inside a file named code.py and executed successfully, which of the following expressions evaluate to True? (Choose two.)

  1. str(Object) = 'Object'
  2. __name__ == '__main__'
  3. len(ClassB.__bases__) == 1
  4. ClassA.__module__ == 'ClassA'

Question 24

Assuming that the following inheritance set is in force, which of the following classes are declared properly? (Choose two.)

  1. class Class_3(A,C): pass
  2. class Class_2(B,C): pass
  3. class Class_4(A,B): pass
  4. class Class_1(C,B): pass

Question 25

Assuming that the following piece of code has been executed successfully, which of the expressions evaluate to True? (Choose two.)

  1. A.VarA == 1
  2. isinstance(obj_b,A)
  3. B.VarA == 1
  4. obj_a is obj_aa