Core Syntax Flashcards
7 cards from real Python practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Core Syntax flashcards as text
What is the output of `print(type(3/2))` in Python 3?
Answer:
In Python 3, the `/` operator always performs true division, returning a float even when dividing two integers.
Which statement correctly creates a multi-line string in Python?
Answer: s = """line1 line2"""
Triple-quoted strings (""" or ''') can span multiple lines and preserve newlines literally.
What does the `//` operator do in Python?
Answer: Performs floor (integer) division
The `//` operator performs floor division, rounding the result down to the nearest integer.
What is the value of `bool('')` in Python?
Answer: False
An empty string is falsy in Python, so `bool('')` evaluates to `False`.
Which of the following is a valid variable name in Python?
Answer: _total
Variable names can start with a letter or underscore, making `_total` valid; `2count` starts with a digit, `my-var` contains a hyphen, and `class` is a reserved keyword.
What is the result of `'5' + '3'` in Python?
Answer: '53'
The `+` operator on strings performs concatenation, so `'5' + '3'` yields the string `'53'`.
Which keyword is used to define an anonymous function in Python?
Answer: lambda
The `lambda` keyword creates a small anonymous function that can have any number of arguments but only one expression.