PCAP 31 03 PCAP Certified Associate Python Programmer Exam Questions & Answers

Practice 61 free PCAP 31 03 PCAP Certified Associate Python Programmer exam questions with answers and community-discussed explanations. Each question has its own page where you can reveal the correct answer and debate it in the comments.

All 61 questions

  1. Q1 Q349 - Data TypesYou are an intern for ABC electric cars company.You must create a function that calculates the average velocityof their…
  2. Q2 Q137 - Data TypesWhat is the expected output of the following code?z = y = x = 1print(x, y, z, sep='*')
  3. Q3 Q380 - Data AggregatesWhat is the expected output of the following code?source = [1, 2, 4, 8, 16]target = [x // 2…
  4. Q4 Q690 - OOPWhich of the following classes contain a usable constructor?(Select two answers.)
  5. Q5 Q174 - I/OAssuming that the open() invocation has gone successfully, the following snippet will:for x in open('file', 'rt'): print(x)
  6. Q6 Q2000 - OOPWhat is true about Object-Oriented Programming in Python?(Select two answers)
  7. Q7 Q354 - ModulesA predefined Python variable, storing the module name, is called:
  8. Q8 Q595 - OOPGiven the code below,which of the expressions will evaluate to True?class Alpha: def say(self): return "alpha"  class Beta(Alpha): def say(self): return…
  9. Q9 Q208 - OperatorsWhat is the expected output of the following code?x = Truey = Falsex = x or yy = x and…
  10. Q10 Q109 - Data AggregatesWhat is the expected output of the following code?list1 = [1, 3]list2 = list1list1[0] = 4print(list2)
  11. Q11 Q439 - Data TypesWhat is the expected output of the following code?print(not 0)print(not 23)print(not '')print(not 'Peter')print(not None)
  12. Q12 Q426 - OOPWhat is the expected output of the following code?class A: pass  class B(A): pass  class C(B): pass  print(issubclass(A, C))
  13. Q13 Q483 - FunctionsWhat is the expected output of the following code?vect = ["alpha", "bravo", "charlie"]new_vect = map(lambda s: s[0].upper(), vect)print(list(new_vect)[1])
  14. Q14 Q470 - FunctionsLook at the code below:my_tuple = (0, 1, 2, 3, 4, 5, 6)# Insert line of code here.print(foo)Which snippet would…
  15. Q15 Q446 - ModulesThe module has been imported using the following line.from mod import funcHow can you invoke the function?
  16. Q16 Q169 - FunctionsSelect the true statements about the map() function.Choose two.
  17. Q17 Q573 - OOPIf the class constructor is declared in the following way:class Class: def __init__(self, val=0): passWhich one of the assignments is…
  18. Q18 Q235 - Error HandlingWhat is the expected output of the following code?try: print('try')except: print('except')finally: print('finally')
  19. Q19 Q544 - ModulesWhich of the following functions can be used to check if a file exists?
  20. Q20 Q166 - OOPA subclass is usually:
  21. Q21 Q458 - OperatorsEvaluate the following Python arithmetic expression:(3 * (1 + 2) ** 2 - (2 ** 2) * 3)What is the…
  22. Q22 Q637 - Data TypesConsider the following Python code:distance = 1876.23amount = +42E7country = 'Italy'What are the types of the variables distance, amount…
  23. Q23 Q535 - Control FlowWhat is the expected output of the following code?data = [1, 2, [3, 4], [5, 6], 7, [8, 9]]count…
  24. Q24 Q268 - Error HandlingWhich of the following is an example of a Python built-in concrete exception?
  25. Q25 Q213 - FunctionsWhat is the expected output of the following code?def func(message, num=1): print(message * num)  func('Hello')func('Welcome', 3)
  26. Q26 Q471 - ModulesThe sys.stderr stream is normally associated with:
  27. Q27 Q438 - Control FlowWhat would you insert instead of ???so that the program prints TRUE to the monitor?w = 7x = 3y…
  28. Q28 Q405 - FunctionsWhat is the expected output of the following code?def func1(param): return param  def func2(param): return param * 2  def func3(param): return param…
  29. Q29 Q322 - Data AggregatesWhat is the expected output of the following code?data = ()print(data.__len__())
  30. Q30 Q197 - Data AggregatesWhich of the following invocations are valid?(Select two answers)
  31. Q31 Q181 - Control FlowWhat is the expected output of the following code?plane = "Cessna"counter = 0for c in plane * 2: if…
  32. Q32 Q620 - FunctionsWhat is the expected output of the following code?def func(x): if x % 2 == 0: return 1 else: return…
  33. Q33 Q611 - OperatorsWhat is the expected output of the following code?list1 = ['Peter', 'Paul', 'Mary', 'Jane']list2 = ['Peter', 'Paul', 'Mary', 'Jane'] print(list1 is…
  34. Q34 Q516 - Control FlowWhat is the expected output of the following code?marks = [80, 70, 90, 90, 80, 100]average = sum(marks) //…
  35. Q35 Q548 - BasicsWhat is the expected output of the following code?x = '\\\'print(len(x))
  36. Q36 Q546 - ModulesYou need a list of seven numbers of random integer valuesfrom  1 (inclusive) to  7 (inclusive).Which of the following code…
  37. Q37 Q466 - OperatorsThe expression:'mike' > 'Mike'is
  38. Q38 Q497 - Control FlowWhat is the expected output of the following snippet?s = 'abc'for i in len(s): s[i] = s[i].upper()print(s)
  39. Q39 Q442 - FunctionsWhat is the expected output of the following code?def get_names(): names = ['Peter', 'Paul', 'Mary', 'Jane', 'Steve'] return names[2:]  def update_names(names):…
  40. Q40 Q688 - ModulesWhat in true about the built-in dir() mechanismin the context of modules and packages?
  41. Q41 Q565 - I/OThe two basic, mutually exclusive, file open modes are named:
  42. Q42 Q474 - ModulesLook at the code below:import random ## Insert lines of code here.# print(a, b, c)Which lines of code would you insert so…
  43. Q43 Q468 - FunctionsHow many plus signs will be printed?def fun(n): s = '+' for i in range(n): s += s yield s  for…
  44. Q44 Q385 - Error HandlingWhich of the following snippets shows the correct wayof handling multiple exceptions in a single except clause?
  45. Q45 Q302 - OperatorsWhat value will be assigned to the x variable?z = 2y = 1x = y < z or z >…
  46. Q46 Q696 - OOPGiven the code below,indicate the code lines correctly decrementing the __b variable by one.class A: __b = 2  def __init__(self):…
  47. Q47 Q498 - FunctionsWhat is the expected output of the following code?def foo(x, y): return y(x) + (x + 1) print(foo(1, lambda x: x…
  48. Q48 Q415 - Data TypesWhat is the expected output of the following code if the user enters 3 and 2?x = int(input())y =…
  49. Q49 Q177 - Data TypesWhich of the following are valid Python string literals?(Select two answers.)
  50. Q50 Q571 - Data AggregatesA data structure described as LIFO is actually a:
  51. Q51 Q575 - BasicsThe built-in class property called __bases__ is:
  52. Q52 Q495 - OOPGiven the code below,which of the expressions will evaluate to True?class Alpha: value = "Alpha"  def say(self): return self.value.lower()  class Beta(Alpha):…
  53. Q53 Q194 - OOPWhat is the expected behavior of the following snippet?class Team: def show_ID(self): print(self.get_ID())  def get_ID(self): return "anonymous"  class A(Team): def get_ID(self):…
  54. Q54 Q479 - OperatorsWhich of the following expressions evaluates to False and raises no exception?(Select two answers.)
  55. Q55 Q422 - FunctionsWhat is the expected output of the following code?def func1(x): return str(x)  def func2(x): return str(2 * x)  print(func1(1) + func2(2))
  56. Q56 Q633 - OperatorsWhat is the expected output of the following code?x = 28y = 8print(x / y)print(x // y)print(x % y)
  57. Q57 Q282 - FunctionsWhat is the expected output of the following code?def f(a, b): return a(b)  print(f(lambda x: x and True, 1 > 0))
  58. Q58 Q168 - FunctionsWhat is the expected output of the following code?x = lambda a, b: a ** bprint(x(2, 10))
  59. Q59 Q255 - Data AggregatesWhat is the expected output of the following code?data = [[0, 1, 2, 3] for i in range(2)]print(data[2][0])
  60. Q60 Q540 - OperatorsWhat is the data type of x, y, z after executing the following snippet?x = 23 + 42y = '23'…
  61. Q61 Q164 - Error HandlingThe part of your code where you think an exception may occur should be placed inside:

More Python Institute certifications

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need