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
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`.
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.
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.
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.
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`.
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.
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.