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 keyword is used to define a function in Python?
Answer: def
The `def` keyword is used to define a function in Python.
What is the output of `print(2 ** 3)` in Python?
Answer: 8
The `**` operator is exponentiation, so `2 ** 3` equals 2 to the power of 3, which is 8.
Which Python built-in function converts a string to an integer?
Answer: int()
`int()` converts a compatible string or float to an integer value.
What is the correct way to write a single-line comment in Python?
Answer: # This is a comment
Single-line comments in Python begin with the `#` symbol.
What is the output of `print(round(3.567, 2))`?
Answer: 3.57
`round(3.567, 2)` rounds to 2 decimal places, giving 3.57 because the third decimal is 7.
In Python, which of the following correctly creates a multi-line string?
Answer: """line1\nline2"""
Triple quotes (`"""..."""` or `'''...'''`) allow multi-line strings in Python.
What does the `input()` function return in Python 3?
Answer: str
`input()` always returns user input as a string in Python 3, regardless of what the user types.