Python Advanced Flashcards
Learn the advanced vocabulary for programming in Python
What is a ‘decorator’ in Python?
A decorator is a function that modifies the behavior of another function or method.
True or False: A ‘lambda’ function is a named function in Python.
False
Fill in the blank: A __________ is a collection of items that is ordered and changeable in Python.
list
What does ‘PEP’ stand for in Python programming?
Python Enhancement Proposal
What is ‘list comprehension’?
A concise way to create lists using a single line of code with a for loop and an optional condition.
Define ‘generator’ in Python.
A generator is a special type of iterator that yields values one at a time and maintains its state between each call.
Multiple Choice: Which of the following is an immutable data type in Python? A) List B) Dictionary C) Tuple D) Set
C) Tuple
What is ‘exception handling’?
A programming construct that allows a program to deal with unexpected errors during execution.
True or False: A ‘module’ in Python is a file containing Python definitions and statements.
True
What does ‘self’ refer to in a class method?
‘self’ refers to the instance of the class itself.
Fill in the blank: A __________ is a blueprint for creating objects in Python.
class
What is ‘inheritance’ in object-oriented programming?
Inheritance is a mechanism where a new class derives attributes and methods from an existing class.
Define ‘context manager’ in Python.
A context manager is an object that defines the runtime context to be established when executing a ‘with’ statement.
Multiple Choice: Which keyword is used to define a function in Python? A) func B) define C) def D) function
C) def
What is ‘polymorphism’ in Python?
Polymorphism allows methods to do different things based on the object it is acting upon.
True or False: ‘Mutable’ types can be changed after their creation.
True
Fill in the blank: A __________ is a collection of key-value pairs in Python.
dictionary
What is the purpose of the ‘pass’ statement in Python?
The ‘pass’ statement is a null operation; it is syntactically required but does nothing.
Define ‘recursion’.
Recursion is a programming technique where a function calls itself in order to solve a problem.
Multiple Choice: Which of the following is NOT a built-in data type in Python? A) List B) Set C) Array D) Dictionary
C) Array
What is ‘slicing’ in Python?
Slicing is a technique to access a subset of elements from a sequence like a list or a string.
True or False: The ‘with’ statement is used for exception handling.
False
Fill in the blank: The __________ function is used to read a file in Python.
open
What is ‘multithreading’?
Multithreading is a technique where multiple threads are spawned by a process to execute tasks concurrently.