← All PCEP Flashcard Decks

Mixed Deck — All PCEP Topics Flashcards

100 cards from real PCEP practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 20 Mixed Deck — All PCEP Topics flashcards as text
  1. What does `'apple,banana,cherry'.split(',')` return?

    Answer: ['apple', 'banana', 'cherry']

    `split(',')` breaks the string at each comma and returns a list of the resulting substrings.

  2. What is the output of `float('3.14')`?

    Answer: 3.14

    `float()` converts a string representation of a decimal number to a float value.

  3. What does round(3.567, 1) return in Python?

    Answer: 3.6

    round(3.567, 1) rounds to 1 decimal place; since the second decimal is 6 (≥5), it rounds up to 3.6.

  4. Which operator is used to repeat a string in Python?

    Answer: *

    The `*` operator repeats a string a given number of times, e.g., `'ab' * 3` gives `'ababab'`.

  5. What does the "finally" block do in "a try...except" structure?

    Answer: It executes whether an exception is raised or not.

    The `finally` block in a `try...except...finally` structure is guaranteed to execute regardless of whether an exception occurred in the `try` block or was handled by an `except` block. It is typically used for cleanup operations, such as closing files or releasing resources. This ensures that essential finalization steps are always performed, preventing resource leaks.

  6. What is the result of `str(42)`?

    Answer: '42'

    `str()` converts an integer to its string representation, resulting in the string '42'.

  7. What is the output of `'Python'[1:4]`?

    Answer: yth

    Slicing `[1:4]` extracts characters at indices 1, 2, and 3, giving 'yth'.

  8. What is the purpose of a try-except block in Python?

    Answer: To handle exceptions and prevent program crashes

    Try-except blocks catch and handle exceptions that would otherwise terminate the program.

  9. What is the output of the following code? ```python for i in range(2): print(f"Outer {i}") for j in range(2): if j == 1: continue print(f" Inner {j}") ```

    Answer: Outer 0 Inner 0 Outer 1 Inner 0

    The `continue` statement only skips the current iteration of the inner loop. For each outer loop iteration (`i=0` and `i=1`), the inner loop starts. When `j` is 0, it prints. When `j` is 1, the `continue` skips the print statement and the inner loop finishes, then the outer loop proceeds to its next iteration.

  10. What is the output of `max(3, 1, 4, 1, 5, 9)`?

    Answer: 9

    `max()` returns the largest value among its arguments, which is 9 in this case.

  11. What is the result of max(3, 7, 2, 9, 4)?

    Answer: 9

    max() compares all provided arguments and returns the largest, which is 9.

  12. What is the scope of a variable defined inside a function, without using the `global` keyword?

    Answer: Local scope

    A variable that is created (assigned a value) inside a function is local to that function. It can only be accessed from within that function and is destroyed when the function finishes executing.

  13. What is the output of the following code? `print(5 * 2 > 8 and 3 + 4 == 7)`

    Answer: True

    First, the arithmetic and comparison expressions are evaluated. `5 * 2 > 8` becomes `10 > 8`, which is `True`. `3 + 4 == 7` becomes `7 == 7`, which is also `True`. Finally, the logical `and` operator evaluates `True and True`, resulting in `True`.

  14. Which escape sequence represents a newline character in a Python string?

    Answer: \n

    `\n` is the escape sequence for a newline, which moves output to the next line.

  15. What does float("3.14") return in Python?

    Answer: 3.14 (a float)

    float() converts a valid string representation of a decimal number into a floating-point value, returning 3.14.

  16. What will be the output of the following code snippet? ```python for i in range(5): if i == 3: break print(i, end=' ') ```

    Answer: 0 1 2

    The loop iterates through numbers from 0 to 4. The `print` statement executes for `i` values 0, 1, and 2. When `i` becomes 3, the `if` condition is met, and the `break` statement is executed, which terminates the loop immediately.

  17. What is the output of this code? ```python print(1, 2, 3, sep='*', end='\n---\n') print(4, 5, 6, sep='*') ```

    Answer: 1*2*3 --- 4*5*6

    The first `print` call separates the numbers 1, 2, 3 with asterisks and then ends with a newline, three hyphens, and another newline. The second `print` call then executes on a new line, separating 4, 5, 6 with asterisks and using the default `end` value (a single newline).

  18. What is the output of the following code? ```python var = 100 def my_func(): var = 50 print(var) my_func() print(var) ```

    Answer: 50 100

    Inside `my_func`, `var = 50` creates a new local variable named `var` that shadows the global variable. This local variable is printed (50). The global variable `var` remains unchanged, so the final `print(var)` statement prints its original value (100).

  19. Which of the following is a valid use of the global keyword?

    Answer: global x; x = 5

    The global statement declares the name, then a separate assignment sets the value; combining them on one line with = is a SyntaxError.

  20. What will be printed by this code? ```python for num in range(4): if num == 2: break else: print("Done") print(num) ```

    Answer: 2

    The `for` loop's `else` block is executed only if the loop completes its iterations without being terminated by a `break` statement. In this case, the loop breaks when `num` is 2. Therefore, the `else` block is skipped. The final `print(num)` statement prints the last value of `num` before the loop was exited, which is 2.

How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. Exam facts are checked against the official sources listed below. Not reviewed by a subject-matter expert. Editorial policy

Sources & references

Exam facts on this page (fees, format, dates, passing scores) are checked against these official sources; the date is our last check. Editorial policy

  1. pythoninstitute.org — Fees, exam format, passing score, retake fee, score release, time limit, score validity, test delivery, eligibility, retake policy · verified Oct 2026