Define variable in Python.
A storage location identified by a name that holds a value.
What keyword is used to define a function?
The keyword ‘def’ is used to define a function.
True or false: Lists are immutable in Python.
FALSE
Lists can be modified after creation.
Fill in the blank: A tuple is defined using _______ parentheses.
Round
What does PEP stand for in Python?
Python Enhancement Proposal.
Define dictionary in Python.
A collection of key-value pairs, where each key is unique.
What is the purpose of the if statement?
To execute a block of code conditionally based on a boolean expression.
True or false: Strings can be modified in Python.
FALSE
Strings are immutable; any modification creates a new string.
What is the output of print(2 ** 3)?
8, as it calculates 2 raised to the power of 3.
Fill in the blank: A loop is used for _______ over a sequence.
Iterating
What does the len() function do?
It returns the number of items in an object.
Define list comprehension.
A concise way to create lists using a single line of code.
What is the purpose of the return statement?
To exit a function and optionally pass an expression back to the caller.
True or false: Comments in Python start with #.
TRUE
What is a module in Python?
A file containing Python code that can be imported and used in other programs.
Fill in the blank: The input() function is used to _______ user input.
Receive
What is the purpose of the with statement?
To wrap the execution of a block with methods defined by a context manager.
Define exception handling.
The process of responding to the occurrence of exceptions during program execution.
What does the break statement do in a loop?
It terminates the loop and transfers control to the statement following the loop.
True or false: Sets can contain duplicate elements.
FALSE
Sets automatically remove duplicates.
What is the purpose of the pass statement?
To act as a placeholder in code where no action is required.
Fill in the blank: A class is a blueprint for creating _______ in Python.
Objects
What is the output of print(type([]))?
<class ‘list’>, indicating that the object is a list.
Define lambda function.
An anonymous function defined with the keyword ‘lambda’.