What is the primary role of the 'self' parameter in Python class methods?
It stores the return value of the method.
It refers to the class itself, allowing access to class variables.
It refers to the current instance of the class, allowing access to instance variables and methods.
It's a placeholder that doesn't have any specific purpose.
Which data structure would be most appropriate for representing a graph in Python?
All of the above options can be used to represent a graph.
A set of tuples, where each tuple represents an edge between two nodes.
A list of lists, where each inner list represents a node and its connections.
A dictionary where keys are nodes, and values are lists of their neighbors.
Which module would you use to interact with the operating system, like creating directories?
datetime
sys
math
os
Which module is used to work with CSV (Comma Separated Values) files in Python?
file
csv
data
text
Which regular expression will match any string that starts with 'a' and ends with 'z'?
'^a.*z$'
'a.+z'
'a.*z'
'^a.+z$'
Which string method is used to determine if a string ends with a specified suffix?
endswith()
startswith()
index()
find()
How can you access the constant 'pi' from the 'math' module after importing it?
math(pi)
pi
math.pi
math->pi
What is the difference between *args and **kwargs in Python?
*args passes a list of arguments, while **kwargs passes a dictionary of arguments.
*args is used for passing arguments by value, while **kwargs is used for passing arguments by reference.
*args passes a variable number of positional arguments, while **kwargs passes a variable number of keyword arguments.
There is no difference; both *args and **kwargs can be used interchangeably.
What is a key characteristic of a closure in Python?
It forces a function to return a value of a specific data type.
It allows a nested function to 'remember' and access variables from its enclosing function's scope even after the outer function has finished executing.
It allows a function to be defined inside a class.
It prevents a function from accessing global variables.
What is the primary purpose of using inheritance in Python's Object-Oriented Programming?
To enhance data security within a program
To enforce strict data type checking
To improve code execution speed
To reduce code duplication and promote reusability