Sign In
Home/Python Institute/PCAP/Free questions

PCAP — Free Practice Questions

10 free sample questions from a bank of 160, with the correct answers and explanations. No signup required — start practising right now.

1What will be the value of the i variable when the while e loop finishes its execution?
PCAP question 1
  • 1
  • 0
  • 2
  • the variable becomes unavailable
Answer: A
2What is the expected output of the following snippet?
PCAP question 2
  • 3
  • 1
  • 2
  • the code is erroneous
Answer: D
3What is true about Python class constructors? (Choose two.)
  • there can be more than one constructor in a Python class
  • the constructor must return a value other than None
  • the constructor is a method named __init__
  • the constructor must have at least one parameter
Answer:
4Assuming that the following piece of code has been executed successfully, which of the expressions evaluate to True? (Choose two.)
PCAP question 4
  • isinstance (obj_b,A)
  • A.VarA == 1
  • obj_a is obj_aa
  • B.VarA == 1
Answer:
5Assuming that the code below has been executed successfully, which of the expressions evaluate to True? (Choose two.)
PCAP question 5
  • len(Class.__dict__) == 1
  • 'data' in Class.__dict__
  • 'var' in Class.__dict__
  • 'data' in Object.__dict__
Answer:
6A property that stores information about a given class's super-classes is named:
  • __upper__
  • __super__
  • __ancestors__
  • __bases__
Answer: D
7Which of the following lines of code will work flawlessly when put independently inside the add_new() method in order to make the snippet's output equal to [0, 1, 2]? (Choose two.)
PCAP question 7
  • self.queue.append(self.get_last() + 1)
  • self.queue.append(get_last() + 1)
  • self.queue.append(self.queue[-1] + 1)
  • queue.append(self.get_last() + 1)
Answer:
8What is the expected output of the following code?
PCAP question 8
  • a
  • c
  • an exception is raised
  • b
Answer: B
9What is the expected output of the following code if there is no file named non_existing_file inside the working directory?
PCAP question 9
  • 1 2 4
  • 1 2 3 4
  • 2 4
  • 1 3
Answer: D
10What is the expected output of the following code if the file named existing_text_file is a non-zero length text file located inside the working directory?
PCAP question 10
  • the length of the first line from the file
  • -1
  • the number of lines contained inside the file
  • the length of the last line from the file
Answer: B

Want the full bank of 160 questions for PCAP? See all practice exams.