Docsity

PYTHON INSTITUTE CERTIFIED ENTRY-LEVEL PYTHON PROGRAMMER (PCEP) ACTUAL EXAM AND PRACTICE T, Exams of Computer Science

Toggle sidebar
bg1
PYTHON INSTITUTE CERTIFIED ENTRY-LEVEL PYTHON
PROGRAMMER (PCEP) ACTUAL EXAM AND PRACTICE
TESTS NEWEST 2026-2027 WITH COMPLETE QUESTIONS
AND CORRECT DETAILED ANSWERS| BRAND NEW
VERSION!
1. Which of the following is the correct way to display text in Python?
A. echo("Hello World")
B. printf("Hello World")
C. print("Hello World")
D. display("Hello World")
Correct Answer: C. print("Hello World")
Rationale: The print() function displays text and other objects to the standard
output in Python.
2. Which symbol is used to begin a single-line comment in Python?
A. //
B. #
C. /*
D. --
Correct Answer: B. #
Rationale: Python uses the hash symbol (#) to indicate a single-line comment.
3. Which of the following is a valid Python variable name?
A. 2value
B. my-value
C. my_value
D. class
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f

Partial preview of the text

Download PYTHON INSTITUTE CERTIFIED ENTRY-LEVEL PYTHON PROGRAMMER (PCEP) ACTUAL EXAM AND PRACTICE T and more Exams Computer Science in PDF only on Docsity!

PYTHON INSTITUTE CERTIFIED ENTRY-LEVEL PYTHON

PROGRAMMER (PCEP) ACTUAL EXAM AND PRACTICE

TESTS NEWEST 2026 - 2027 WITH COMPLETE QUESTIONS

AND CORRECT DETAILED ANSWERS| BRAND NEW

VERSION!

1. Which of the following is the correct way to display text in Python? A. echo("Hello World") B. printf("Hello World") C. print("Hello World") D. display("Hello World") Correct Answer: C. print("Hello World") Rationale: The print() function displays text and other objects to the standard output in Python. 2. Which symbol is used to begin a single-line comment in Python? A. // B. # C. /* D. -- Correct Answer: B. # Rationale: Python uses the hash symbol (#) to indicate a single-line comment. 3. Which of the following is a valid Python variable name? A. 2value B. my-value C. my_value D. class

Correct Answer: C. my_value Rationale: Python variable names can contain letters, digits, and underscores but cannot begin with a digit or use reserved keywords.

4. What is the output of the following code? print(5 + 3 * 2) A. 16 B. 13 C. 11 D. 10 Correct Answer: C. 11 Rationale: Multiplication has higher precedence than addition, so 3 × 2 is evaluated first, followed by 5 + 6. 5. Which data type represents whole numbers in Python? A. float B. str C. int D. bool Correct Answer: C. int Rationale: The int data type represents integer values without fractional components. 6. What is the result of the following expression? 10 / 2 A. 5 B. 5. C. 2 D. 10 Correct Answer: B. 5.

print(type(3.14)) A. B. C. D. Correct Answer: B. Rationale: Decimal numeric literals such as 3.14 are represented by Python's float type.

11. Which value represents Boolean false in Python? A. "False" B. 0 C. None D. False Correct Answer: D. False Rationale: False is the Boolean literal representing the false logical value. Although 0 and None are also falsy, they are not the Boolean value False. 12. What is the output? print(bool(0)) A. True B. False C. 0 D. None Correct Answer: B. False Rationale: The integer zero is a falsy value, so bool(0) returns False. 13. Which operator checks whether two values are equal? A. = B. == C. != D. :=

Correct Answer: B. == Rationale: The equality operator (==) compares two values and returns True when they are equal.

14. What is the output? x = 5x += 3print(x) A. 5 B. 3 C. 8 D. 15 Correct Answer: C. 8 Rationale: The augmented assignment operator += adds three to the existing value of x. 15. Which statement is used to execute code conditionally? A. repeat B. if C. define D. switch Correct Answer: B. if Rationale: The if statement evaluates a condition and executes its indented block when the condition is true. 16. What is the output? x = 10if x > 5: print("High")else: print("Low") A. High B. Low C. 10 D. Error Correct Answer: A. High

A. Adds two values B. Reverses a Boolean value C. Compares two strings D. Converts a float to an integer Correct Answer: B. Reverses a Boolean value Rationale: The not operator performs logical negation, changing True to False and False to True.

21. Which loop is commonly used to iterate over a sequence? A. if B. for C. def D. class Correct Answer: B. for Rationale: A for loop iterates over the elements of an iterable such as a list, tuple, string, or range. 22. What is the output? for i in range(3): print(i) A. 1 2 3 B. 0 1 2 C. 0 1 2 3 D. 3 2 1 Correct Answer: B. 0 1 2 Rationale: range(3) generates the integers 0, 1, and 2 because the stop value is excluded. 23. Which function generates a sequence of numbers? A. sequence() B. numbers() C. range() D. listnum()

Correct Answer: C. range() Rationale: The range() function produces an immutable sequence of integers commonly used in loops.

24. What is the output? x = 0while x < 3: x += 1print(x) A. 0 B. 2 C. 3 D. 4 Correct Answer: C. 3 Rationale: The loop increments x until it reaches 3, at which point the condition becomes false. 25. Which keyword immediately terminates a loop? A. stop B. exit C. break D. continue Correct Answer: C. break Rationale: The break statement terminates the nearest enclosing loop immediately. 26. What does the continue statement do? A. Terminates the entire program B. Skips the remaining statements in the current iteration C. Restarts the program D. Terminates the function Correct Answer: B. Skips the remaining statements in the current iteration Rationale: The continue statement moves execution to the next iteration of the nearest enclosing loop.

A. 46

B. 10

C. 4

D. 6

Correct Answer: B. 10 Rationale: The function receives 4 and 6, adds them, and returns the integer 10.

31. What is the default return value of a function without an explicit return statement? A. 0 B. False C. None D. Empty string Correct Answer: C. None Rationale: Python functions that do not explicitly return a value return None automatically. 32. Which of the following correctly defines a function with a default parameter? A. def greet(name = "John"): B. function greet(name = "John"): C. def greet(name == "John"): D. greet def(name = "John") Correct Answer: A. def greet(name = "John"): Rationale: Python allows default parameter values to be assigned using the equals sign in a function definition. 33. What is the output? name = "Python"print(len(name)) A. 5 B. 6

C. 7

D. 8

Correct Answer: B. 6 Rationale: The len() function returns the number of characters in the string Python, which is six.

34. Which data type stores an ordered collection of elements that can be modified? A. Tuple B. String C. List D. Integer Correct Answer: C. List Rationale: Lists are ordered, mutable collections that can contain elements of different data types. 35. Which syntax correctly creates a Python list? A. {1, 2, 3} B. (1, 2, 3) C. [1, 2, 3] D. 1, 2, 3 Correct Answer: C. [1, 2, 3] Rationale: Square brackets are used to create list literals in Python. 36. What is the output? numbers = [10, 20, 30]print(numbers[1]) A. 10 B. 20 C. 30 D. 1 Correct Answer: B. 20

A. [5, 10, 15]

B. [10, 15]

C. [5, 10]

D. [5, 15]

Correct Answer: C. [5, 10] Rationale: The pop() method without an index removes and returns the last element of the list.

41. Which collection is ordered and immutable? A. List B. Dictionary C. Set D. Tuple Correct Answer: D. Tuple Rationale: A tuple maintains element order and does not allow its elements to be reassigned or added or removed after creation. 42. Which syntax creates a tuple containing one element? A. (5) B. [5] C. (5,) D. {5} Correct Answer: C. (5,) Rationale: A comma is required to distinguish a single-element tuple from a parenthesized expression. 43. What is the output? values = (10, 20, 30)print(values[2]) A. 10 B. 20 C. 30 D. Error

Correct Answer: C. 30 Rationale: Tuple indexing starts at zero, making the element at index 2 equal to

44. Which data type stores unique elements without maintaining a guaranteed insertion order? A. List B. Set C. Tuple D. String Correct Answer: B. Set Rationale: A set stores unique elements and does not guarantee insertion-order iteration. 45. What happens when a duplicate value is added to a set? A. The program always crashes B. The duplicate is stored twice C. The duplicate is ignored D. The set becomes a list Correct Answer: C. The duplicate is ignored Rationale: Sets automatically eliminate duplicate elements, so adding an existing element does not create another entry. 46. Which syntax creates an empty dictionary? A. [] B. () C. {} D. set() Correct Answer: C. {} Rationale: Curly braces without key-value pairs create an empty dictionary. An empty set is created using set(). 47. Which dictionary method returns the value associated with a specified key?

C. n D. Python Correct Answer: B. P Rationale: String indexing starts at zero, so index 0 retrieves the first character, P.

51. What is the output of the following code? text = "Python Programming"print(text.lower()) A. PYTHON PROGRAMMING B. Python Programming C. python programming D. Python programming Correct Answer: C. python programming Rationale: The lower() method converts all alphabetic characters in a string to lowercase. 52. Which string method converts all alphabetic characters to uppercase? A. capitalize() B. upper() C. title() D. uppercase() Correct Answer: B. upper() Rationale: The upper() method returns a new string with all lowercase letters converted to uppercase. 53. What is the output? text = "Python"print(text[1:4]) A. Pyt B. yth C. tho D. ytho Correct Answer: B. yth

Rationale: String slicing includes the starting index but excludes the ending index. Therefore, indexes 1, 2, and 3 are returned.

54. What is the output? text = "PROGRAM"print(text[-1]) A. P B. R C. A D. M Correct Answer: D. M Rationale: Negative indexing starts from the end of a string, where index - 1 represents the final character. 55. Which operator concatenates two strings? A. * B. + C. % D. // Correct Answer: B. + Rationale: The plus operator concatenates strings by joining their contents into a new string. 56. What is the output? print("Py" * 3) A. Py B. PyPyPy C. Py Py Py D. Error Correct Answer: B. PyPyPy Rationale: Multiplying a string by an integer repeats the string the specified number of times.

A. 1

B. 2

C. 3

D. 4

Correct Answer: C. 3 Rationale: The count() method returns the number of occurrences of the specified substring. The letter a appears three times.

61. Which function converts a string containing a valid numeric representation into a floating-point number? A. int() B. float() C. str() D. list() Correct Answer: B. float() Rationale: The float() function converts compatible numeric values and numeric strings into floating-point numbers. 62. What is the output? x = "25"y = int(x)print(y + 5) A. 255 B. 30 C. 25 D. Error Correct Answer: B. 30 Rationale: The int() function converts the string "25" into the integer 25, allowing normal arithmetic addition. 63. What happens when the following code executes? print(int("hello")) A. Prints 0 B. Prints hello

C. Raises a ValueError D. Raises a TypeError Correct Answer: C. Raises a ValueError Rationale: The string "hello" does not represent a valid integer, so int() raises a ValueError.

64. Which exception is raised when attempting to divide a number by zero? A. ValueError B. TypeError C. ZeroDivisionError D. IndexError Correct Answer: C. ZeroDivisionError Rationale: Python raises ZeroDivisionError when an arithmetic division operation uses zero as its divisor. 65. Which statement is used to handle exceptions in Python? A. try-except B. if-else C. for-while D. def-return Correct Answer: A. try-except Rationale: The try-except structure allows a program to catch and handle specified exceptions instead of terminating unexpectedly. 66. What is the output? try: print(10 / 0)except ZeroDivisionError: print("Cannot divide by zero") A. 10 B. 0 C. Cannot divide by zero D. Program terminates without output Correct Answer: C. Cannot divide by zero