โ† All PCEP Flashcard Decks

Fundamentals of Python Programming Flashcards

7 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 7 Fundamentals of Python Programming flashcards as text
  1. What is the result of `type(True)` in Python?

    Answer:

    `True` is of type `bool` in Python, even though `bool` is a subclass of `int`.

  2. Which of the following correctly uses the `print()` function to display text without a newline at the end?

    Answer: print('text', end='')

    The `end` parameter of `print()` controls what character is printed at the end; `end=''` suppresses the newline.

  3. What is the output of `print(int(3.9))` in Python?

    Answer: 3

    `int()` truncates toward zero, so `int(3.9)` returns 3, not the rounded value 4.

  4. In Python, which of the following is the correct logical operator for 'and'?

    Answer: and

    Python uses the keyword `and` for logical AND operations, not `&&` like some other languages.

  5. What is the output of `print(10 / 2)` in Python 3?

    Answer: 5.0

    In Python 3, `/` always performs true division and returns a float, so `10 / 2` is `5.0`.

  6. What built-in function can be used to find the maximum value among several numbers?

    Answer: max()

    The `max()` built-in function returns the largest value among its arguments or from an iterable.

  7. Which of the following is a correct way to swap the values of two variables `a` and `b` in Python?

    Answer: a, b = b, a

    Python supports simultaneous assignment, so `a, b = b, a` swaps values without a temporary variable.