Python PCAP (31-03) Exam Questions 2026 Python PCAP (31-03) Questions 2026 Contains 730+ exam questions to pass the exam in first attempt. SkillCertPro offers real exam questions for practice for all major IT certifications. For a full set of 750 questions. Go to https://skillcertpro.com/product/python - pcap - 31 - 03 - exam - que stions/ SkillCertPro offers detailed explanations to each question which helps to understand the concepts better. It is recommended to score above 85% in SkillCertPro exams before attempting a real exam. SkillCertPro updates exam questions every 2 weeks. You will get life time access and life time free updates SkillCertPro assures 100% pass guarantee in first attempt. Below are the free 10 sample questions. Question 1: Which statement below returns True (check all that apply) ? A. range(10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] B. range(0, 3, 2) == range(0, 4, 2) C. list(range(0)) == [0] D. list(range(0, -10, -1)) == [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] Answer: B and D Explanation: Knowledge Area : Control Flow – loops and conditional blocks Topic : range() More details: The range() type represents an immutable sequence of numbers. It can be used with one argument : range(stop) where stop is the last number in the sequence (excluded) – in this case default start number is 0 and the default step is 1. Or with 2 or 3 arguments : range(start, stop[, step]) The start, stop, step arguments must be integer. Pease refer to the section below for additional details on each suggested answers. Try it yourself: # range(0, 3, 2) is a sequence of 0,2 # same with range(0, 4, 2) print(range(0, 3, 2) == range(0, 4, 2)) # True # range(0) is an empty sequence, so list(range(0)) == [] print(list(range(0)) == [0]) # False # range(10) does not return a list print(range(10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) # False # stop and step can be negative integers print(list(range(0, -10, -1)) == [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) # True Question 2: What is the expected output of the following code? x = range(3, 12, 3) for n in x: if (n%2 == 0): print(n, end=‘‘) else: pass else: print(sum(x)) A. 6918 B. 618 C. 612 D. 61218 Answer: B Explanation: Knowledge Area : Control Flow – loops and conditional blocks Topic : range() , for-else loop, % operator More details: The range(start, stop, step) function creates a sequence (iterable) based on the following parameters: start (Optional) : An integer number specifying at which position to start. Default is 0 stop (Required) : An integer number specifying at which position to stop (not included). step (Optional): An integer number specifying the incrementation. Default is 1 so range(3,12,3) returns the following sequence : [3,6,9] Looping through this sequence, only 6 is even (n%2 == 0 is True when n=6), so only 6 gets printed to the screen. The else keyword in a for loop specifies a block of code to be executed when the loop is finished – in this case, print(sum(x)) is executed : the sum() function adds the items of an iterable and returns the sum; in this case : sum([3,6,9]) returns 18. So the end result is : 618 Try it yourself: x = range(3, 12, 3) for n in x: if (n%2 == 0): print(n, end=‘‘) # 6 else: pass else: print(sum(x)) # 18 Question 3: What is the expected output of the following code snippet ? i=0 while i in range(1,11,2): print(i, end=‘‘) else: print(‘*‘) A.1357911* B. 13579* C. 13579 D. * Answer: D Explanation: Knowledge Area : Control Flow – loops and conditional blocks Topic : while-else loop More details: With a while loop, the code within the loop will get repeated as long as the condition in the while statement is True. Once the loop has exited, the else: branch gets executed (unless the while loop was terminated with a break statement). Here variable i gets initialized with a value of 0, and 0 is not in range(1,11,2). So the code within the while branch does not get executed and the code within the else: branch is triggered : * is printed to the monitor. Try it yourself: i=0 while i in range(1,11,2): # 0 is not in range(1,11,2) print(i, end=‘‘) else: print(‘*‘) # * Question 4: Assuming the variables x, y and z have been defined as follow : x = 5%2 y = 2**0 z = [False] Which of the following statements is true ? A. print(not bool(y)) prints True B. print(bool(z)) prints False C. print(bool(x) == bool(y)) prints False D. print(bool(y) and bool(x)) prints True Answer: D Explanation: Knowledge Area : Data Types, Evaluations, and Basic I/O Operations Topic : bool() function, boolean operators (and, not) , relational operators (==), % (modulo) operator, ** (exponentiation) operator More details: 5%2 returns 1 . So x = 1 2**0 returns 1 . So y =1 z is a list with one value (it does not matter if this value is the boolean False !) , so bool(z) is True. bool(1) returns True. so, bool(y) and bool(x) is equivalent to True and True which is True. and bool(y) == bool(x) is equivalent to True == True which is True. Finally, not bool(y) is equivalent to not True which is False. Try it yourself: x = 5%2 y = 2**0 z = [False] print(x) # 1 print(y) # 1 print(bool(z)) # True print(bool(y)) # True print(bool(x)) # True print(bool(y) and bool(x)) # True print(bool(x) == bool(y)) # True print(not bool(y)) # False Question 5: Which statement about operators and their priorities is correct ? A. Operator / has a higher priority than * . B. Binary operators + and - have a lower priority than *. C. Operator * has a higher priority than ** . D. Unary operators + and - have a lower priority than **. Answer: B and D Explanation: Knowledge Area : Basic Concepts Topic : priority of operators More details: The priority of operators is as follow (by decreasing order of priority): 1 – ** (exponentiation) 2 – unary + and – 3 – *, /, and % 4 – binary + and -. Try it yourself: print(2**3*4) # 32 print(2*3+2*4) # 14 For a full set of 750 questions. Go to https://skillcertpro.com/product/python - pcap - 31 - 03 - exam - questions/ SkillCertPro offers detailed explanations to each question which helps to understand the concepts better. I t is recommended to score above 85% in SkillCertPro exams before attempting a real exam. SkillCertPro updates exam questions every 2 weeks. You will get life time access and life time free updates SkillCertPro assures 100% pass guarantee in first attempt Question 6: What is the expected output of the following code? x = {(1, 2): 1, (2, 3): 2} print(x[1, 2]) A. {(1, 2): 1, (2, 3): 2} B. {1,2} C. (1, 2), (2, 3) D. 1 Answer: D Explanation: Knowledge Area : Data Collections – Lists, Tuples, and Dictionaries Topic : dictionaries, tuples More details: x is a dictionary and each of its key is defined as a tuple. As a reminder, a tuple can be defined using parenthesis as in : my_tuple = (1, 2, 4, 8) but also without parenthesis, as in : my_tuple = 1, 2, 4, 8. x[1,2] is simply equivalent to x[(1,2)] which returns the corresponding value from the key (1,2) of the dictionary x, which is 1. Try it yourself: x = {(1, 2): 1, (2, 3): 2} print(x[1, 2]) # 1 print(x[(1, 2)]) # 1 Question 7: Which statement(s) below will return True ? A. bool(4**0) B. bool(None) C. bool(‘False‘) D. bool([]) Answer: A and C Explanation: Knowledge Area : Basic Concepts Topic : Boolean and the bool() function More details: The bool() function converts a value to Boolean (True or False). The following values are considered false in Python: – None – False – Zero (any numeric type) – Empty sequence (list, tuple, empty string, etc...). For example, (), [], ‘‘. – Empty mapping. For example, {} In the above question : – ‘False‘ is a non - empty string, so bool(‘False‘) returns True – 4**0 returns 1 – so bool(4**0) returns True Try it yourself: print(bool([])) # False print(bool(‘False‘)) # True print(bool(4**0)) # True print(bool(None)) # False Question 8: What is the expected output of the following snippet ? x = 3 y = 2 z = 3 def my_func(x,y,z=1): return(x**y**z) print(my_func(x=2,y,z)) A.The code is erroneous. B. 256 C. 64 D. 4 Answer: A Explanation: Knowledge Area : Functions Topic : positional keyword and mixed argument passing More details: Function my_func() takes three parameters (x,y,z). Those three parameters are unrelated to the variables x, y and z defined outside of the function. The call to the function my_func() in the last line of the code (my_func(x=2,y,z)) is done using both keyword argument passing (x=2) and positional argument passing (y,z) – mixing those two methods of argument passing is acceptable provided that positional arguments does NOT follow keyword arguments. So, my_func(x=2,y,z) would raise a runtime exception since the positional arguments follow the keyword argument (x=2). There are valid ways to call the function – see below for examples. Try it yourself: x = 3 y = 2 z = 3 def my_func(x,y,z=1): return(x**y**z) print(my_func(x=2,y,z)) # SyntaxError: positional argument follows keyword argument print(my_func(2,y,z)) # 256 print(my_func(2,y=y,z=z)) # 256 print(my_func(2,y=y)) # 4 Question 9: What is the output of the following snippet of the user enters two lines containing 2 and 4 respectively ? x = input() y = int(input()) print(x * y) A.2222 B. 8 C. 2 * 4 D. The code is erroneous. Answer: A Explanation: Knowledge Area : Data Types, Evaluations, and Basic I/O Operations Topic : input() , * operator with one string , int() More details: The input() function always returns a string. So x is a string. The int() function converts its argument (string, float, etc...) to an int. So, y is an int. The * operator can be used with one string ABC and an int x : the result will be the string ABC repeated x times. Try it yourself: x = input(“Enter x:“) # enter 2 print(type(x)) # y = int(input(“Enter y:“)) # enter 4 print(type(y)) # print(x * y) # 2222 Question 10: What is the expected output of the following code ? y = ‘R2D2‘ def my_func(x): global y y = x return y x = ‘Yoda‘ my_func(‘C3PO‘) print(y) A. Yoda B. R2D2 C. C3PO D. The code is erroneous. Answer: C Explanation: Knowledge Area : Functions Topic : global keyword More details: When you create a variable inside a function, that variable has a local scope, and can only be used inside that function. With the global keyword, the scope of that variable will be extended to outside the function too. The call to my_func(‘C3PO‘) will assign ‘C3PO‘ to the global variable y and print(y) will return C3PO. Try it yourself: y = ‘R2D2‘ def my_func(x): global y y = x return y x = ‘Yoda‘ my_func(‘C3PO‘) print(y) # C3PO For a full set of 750 questions. Go to https://skillcertpro.com/product/python - pcap - 31 - 03 - exam - questions/ SkillCertPro offers detailed explanations to each question which helps to understand the concepts better. It is recommended to score above 85% in SkillCertPro exams before attempting a real exam. SkillCertPro updates exam questions every 2 weeks. You will get life time access and life time free updates SkillCertPro assures 100% pass guarantee in first attempt.