Define Python.
A high-level, interpreted programming language known for its readability and versatility.
What does PEP stand for in Python?
Python Enhancement Proposal, a design document providing information to the Python community.
True or false: Python is a compiled language.
FALSE
Python is an interpreted language, meaning code is executed line by line.
Fill in the blank: Python uses ______ to define code blocks.
Indentation
What is a list in Python?
A mutable, ordered collection of items, defined by square brackets.
Define tuple.
An immutable, ordered collection of items, defined by parentheses.
What is the purpose of the print() function?
To output data to the console.
True or false: Python supports multiple inheritance.
TRUE
A class can inherit from multiple parent classes in Python.
What does the len() function do?
Returns the number of items in an object.
Fill in the blank: A dictionary in Python is defined using ______.
Curly braces
What is the purpose of if statements?
To execute a block of code conditionally based on a boolean expression.
Define list comprehension.
A concise way to create lists using a single line of code.
What is a function in Python?
A block of reusable code that performs a specific task.
True or false: Python uses static typing.
FALSE
Python uses dynamic typing, allowing variable types to change at runtime.
What is the purpose of the import statement?
To include external modules or libraries in your code.
Fill in the blank: The __init__() method is the ______ method in a class.
Constructor
What is an exception in Python?
An error that occurs during program execution, disrupting normal flow.
Define lambda function.
A small anonymous function defined with the keyword ‘lambda’.
What is the purpose of the with statement?
To simplify exception handling by encapsulating common preparation and cleanup tasks.
True or false: Python supports regular expressions.
TRUE
The ‘re’ module provides support for regular expressions in Python.
What is the main() function?
The entry point of a Python program, executed when the script runs.
Fill in the blank: The for loop iterates over ______.
A sequence
What is a module in Python?
A file containing Python code that can define functions, classes, and variables.
Define decorator.
A function that modifies the behavior of another function.