Sample questions
Certified Entry-Level Python Programmer PCEP practice questions
According to PEP 8, which of the following is the recommended way to name a constant representing the maximum number of retries?
Computer Programming and Python FundamentalshardSee the answer and why each option is right or wrong →A developer writes a function that takes a tuple as an argument and tries to modify an element inside the tuple. What happens?
Functions, Tuples, Dictionaries and ExceptionseasySee the answer and why each option is right or wrong →The exhibit shows a JSON configuration. Which Python data structure is best suited to represent this configuration?
Computer Programming and Python FundamentalseasySee the answer and why each option is right or wrong →What is the output of the code in the exhibit?
Data Types, Variables, Basic I/O and OperatorsmediumSee the answer and why each option is right or wrong →A system administrator is writing a Python script to monitor server uptime. The script reads a log file line by line, parses timestamps, and stores them in a list. It then loops th…
What does 'print(2 ** 3)' output?
Data Types, Variables, Basic I/O and OperatorseasySee the answer and why each option is right or wrong →Given the code: x = 10; y = 3.0; z = x / y; print(type(z)). What is the output?
Data Types, Variables, Basic I/O and OperatorshardSee the answer and why each option is right or wrong →Given the code: my_list = [1, 2, 3, 4, 5]. What is the output of print(my_list[-3:-1])?
Computer Programming and Python FundamentalshardSee the answer and why each option is right or wrong →A Python script calculates the area of a circle: radius = 5; area = 3.14 * radius ** 2; print(area). What is printed?
Computer Programming and Python FundamentalseasySee the answer and why each option is right or wrong →Which loop is more efficient for iterating over a large list when you only need the values, not indices?
Which TWO of the following exceptions are built-in Python exceptions? (Select exactly 2)
Functions, Tuples, Dictionaries and ExceptionseasySee the answer and why each option is right or wrong →A developer runs the command and sees the output. Which statement about the data type is correct?
Data Types, Variables, Basic I/O and OperatorsmediumSee the answer and why each option is right or wrong →You are working on a network automation script that reads a configuration file containing firewall rules. Each rule is a dictionary with keys 'source_ip', 'dest_ip', 'action'. The…
What will be printed? ```python my_list = [] my_list.append('192.168.1.10') my_list.append('255.255.255.0') my_list.append('192.168.1.1') print(my_list) ```
Computer Programming and Python FundamentalsmediumSee the answer and why each option is right or wrong →A developer needs to determine the number of elements in a tuple named 't'. Which code snippet will correctly return the length?
Functions, Tuples, Dictionaries and ExceptionseasySee the answer and why each option is right or wrong →A programmer writes: result = 'Py' * 2 + 'thon'. What is the value of result?
Data Types, Variables, Basic I/O and OperatorsmediumSee the answer and why each option is right or wrong →A developer writes a function that modifies a global variable inside the function: count = 0 def increment(): count += 1 When called, an error occurs. What is the correct way…
Computer Programming and Python FundamentalsmediumSee the answer and why each option is right or wrong →A company needs to filter a list of temperatures in Celsius to only those above 0, then convert to Fahrenheit (multiply by 9/5 and add 32). Which code snippet correctly accomplishe…
A programmer is reviewing code that uses loops and conditional statements. Which TWO of the following statements about Python control flow are correct? (Choose two.)
Consider the following code: def foo(x, y): return x * y result = foo(y=2, 3) What is the error?
Functions, Tuples, Dictionaries and ExceptionsmediumSee the answer and why each option is right or wrong →In a try-except block, a developer has two except clauses: except ValueError: and except: (bare except). If the code in the try block raises a ValueError, which except clause is ex…
Functions, Tuples, Dictionaries and ExceptionshardSee the answer and why each option is right or wrong →A programmer needs to swap the values of two variables a and b without using a temporary variable. Which approach works in Python?
Data Types, Variables, Basic I/O and OperatorsmediumSee the answer and why each option is right or wrong →Which three of the following statements about lists are true? (Choose three.)
What is the output of: print(2 ** 3 ** 2)?
Computer Programming and Python FundamentalshardSee the answer and why each option is right or wrong →