
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

































Exam Overview: PCEP - Certified Entry-Level Python Programmer (Exam PCEP- 30 - 02) | 250 comprehensive practice questions | Covers all domains: Basic Concepts, Data Types, Control Flow, Data Collections, Functions & Modules, and Exceptions & File Processing.
Question 1 What is the output of the following code?
print("Hello", "World", sep="-") ## ``` A) Hello-World B) Hello World C) Hello-World- D) "Hello-World" Answer: A) Hello-World Explanation: The `sep` parameter in the `print()` function specifies the separator between multiple arguments. The default separator is a space (' '), but when `sep="-"` is specified, it uses a dash as the separator. Reference: PCEP- 30 - 02 - print() function parameters --- Question 2 Which of the following is a valid variable name in Python? A) 2nd_number B) my-variable Answer: B) 2 Explanation: The `//` operator performs floor division (integer division), returning the integer quotient. 5 // 2 equals 2, with the remainder (1) discarded. Note that the result is an integer, not a float. Reference: PCEP- 30 - 02 - Arithmetic operators --- Question 4 Which of the following is NOT a built-in data type in Python? A) int B) float C) string D) real Answer: D) real Explanation: Python's built-in numeric types are `int`, `float`, and `complex`. There is no `real` data type in Python. `str` is used for strings. Reference: PCEP- 30 - 02 - Built-in data types --- Question 5 What is the output of the following code? ```python x = 10 y = 20 x, y = y, x print(x, y)A) 10 20 B) 20 10 C) 20 20 D) 10 10
Explanation: Python supports string creation using single quotes ('...'), double quotes ("..."), and triple quotes ('''...''' or """..."""). Triple quotes are particularly useful for multi-line strings. Reference: PCEP- 30 - 02 - String literals
Question 7 What is the output of the following code?
x = 5 print(type(x))A) B) C) D) Answer: A)
Explanation: The type() function returns the data type of the specified object. Since x = 5 is an integer, type(x) returns ``. Reference: PCEP- 30 - 02 - type() function
Question 8 What is the value of 2 3 in Python? A) 6 B) 8 C) 9 D) 5 Answer: B) 8 Explanation: The operator performs exponentiation. 2 3 means 2 raised to the power of 3, which equals 2 × 2 × 2 = 8. Reference: PCEP- 30 - 02 - Arithmetic operators
Question 10 Which of the following is NOT a valid identifier in Python? A) my_variable B) my_variable C) 2myVariable D) myVariable Answer: C) 2myVariable Explanation: Identifiers in Python cannot start with a digit. 2myVariable starts with a digit, making it invalid. Identifiers can start with a letter (a-z, A-Z) or underscore (), followed by letters, digits, or underscores. Reference: PCEP- 30 - 02 - Identifiers
Question 11 What is the output of the following code?
print("Hello" 3)A) HelloHelloHello B) Hello Hello Hello C) Hello 3 D) Error Answer: A) HelloHelloHello Explanation: The operator on strings performs repetition. "Hello" 3 creates a string that repeats "Hello" three times, resulting in "HelloHelloHello" (no spaces). Reference: PCEP- 30 - 02 - String repetition
Question 12 Which of the following values is NOT a valid integer in Python? A) 42 B) - 10
D) Error Answer: A) 5 Explanation: In Python, integers are immutable. When b = a is executed, b references the same integer object as a. When a is reassigned to 10, it points to a new object, but b still references the original 5. This demonstrates that integers are immutable. Reference: PCEP- 30 - 02 - Immutability and assignment
Question 14 Which operator is used to calculate the remainder of a division in Python? A) / B) //
Answer: C) % Explanation: The % operator (modulus) returns the remainder after division. For example, 10 % 3 equals 1. The // operator returns the floor division quotient, and / returns float division. Reference: PCEP- 30 - 02 - Arithmetic operators
Question 15 What is the output of the following code?
x = 5 x += 3 print(x)A) 5
Answer: D) array Explanation: While Python does have an array module, array is not a built-in data type. The built-in data types include str, int, float, bool, list, tuple, dict, and set. Reference: PCEP- 30 - 02 - Built-in data types
Question 17 What is the output of the following code?
x = "Python" print(x[0])A) P B) y C) Python D) t
Answer: A) P Explanation: Strings are sequences of characters. Indexing starts at 0, so x[0] returns the first character of the string "Python", which is "P". Reference: PCEP- 30 - 02 - String indexing
Question 18 Which of the following statements about print() is TRUE? A) print() can only accept one argument B) print() always adds a newline at the end by default C) print() cannot print numbers D) print() does not allow custom separators Answer: B) print() always adds a newline at the end by default Explanation: The print() function accepts multiple arguments, prints numbers and strings, allows custom separators with sep,
Question 20 Which of the following is the correct way to escape a quote within a string? A) "She said, "Hello"" B) "She said, "Hello"" C) "She said, 'Hello'" D) Both B and C Answer: D) Both B and C Explanation: You can use backslash escaping (\") to include double quotes inside double-quoted strings, or you can simply use single quotes inside double-quoted strings (or vice versa). Both are correct ways to handle quotes within strings. Reference: PCEP- 30 - 02 - String literals and escaping
Question 21 What is the output of the following code?
x = 5. print(type(x))A) B) C) D) Answer: B) Explanation: A number with a decimal point is considered a float in Python. 5.0 is a float, even though mathematically it is an integer value. Reference: PCEP- 30 - 02 - Floating-point numbers