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.
Define ‘API’ in the context of Python.
API stands for Application Programming Interface, which allows different software programs to communicate with each other.
Multiple Choice: Which of the following is used to handle exceptions? A) try-except B) handle C) catch D) error
A) try-except
What is ‘data encapsulation’?
Data encapsulation is the bundling of data with the methods that operate on that data.
True or False: A ‘set’ is an ordered collection of unique elements.
False
Fill in the blank: The __________ keyword is used to create a new thread in Python.
threading
What is ‘type hinting’?
Type hinting is a feature in Python that allows you to indicate the expected data types of variables and function return values.
Define ‘list slicing’.
List slicing is the process of accessing a range of elements from a list using a specific syntax.
Multiple Choice: Which of the following is a valid way to create a dictionary? A) {} B) [] C) () D) <>
A) {}
What is ‘debugging’?
Debugging is the process of identifying and removing errors from computer software or hardware.
True or False: Python uses indentation to define the scope of loops and functions.
True
Fill in the blank: A __________ is an instance of a class in Python.
object
What is ‘unit testing’?
Unit testing is a software testing method by which individual units of source code are tested to determine if they are fit for use.
Define ‘asynchronous programming’.
Asynchronous programming is a programming paradigm that allows for concurrent execution of tasks without blocking.
Multiple Choice: Which of the following is used to create an empty set? A) [] B) {} C) set() D) ()
C) set()
What is ‘serialization’?
Serialization is the process of converting an object into a format that can be easily stored or transmitted.
True or False: The ‘global’ keyword is used to declare a variable inside a function as global.
True
Fill in the blank: A __________ is a function that is defined inside a class in Python.
method
What is ‘class method’?
A class method is a method that is bound to the class and not the instance of the class.
Define ‘staticmethod’.
A static method is a method that does not receive an implicit first argument and can be called on the class itself.
Multiple Choice: Which of the following is the correct way to import a module? A) import module_name B) include module_name C) require module_name D) using module_name
A) import module_name
What is ‘list concatenation’?
List concatenation is the process of combining two or more lists into a single list.
True or False: The ‘break’ statement is used to exit a loop prematurely.
True
Fill in the blank: A __________ is an ordered collection of elements that can have duplicates.
list
What is ‘self-documenting code’?
Self-documenting code is code that is written in a way that its purpose and function are clear without additional comments.
Define ‘data type’.
A data type is a classification that specifies which type of value a variable can hold.
Multiple Choice: Which of the following is NOT a control flow statement? A) if B) for C) while D) print
D) print
What is ‘module importing’?
Module importing is the process of bringing in external modules into your Python script to use their functionality.
True or False: The ‘continue’ statement skips the current iteration of a loop.
True
Fill in the blank: A __________ is a sequence of characters in Python.
string
What is ‘tuple unpacking’?
Tuple unpacking is the process of assigning the elements of a tuple to multiple variables in a single statement.
Define ‘mocking’ in the context of testing.
Mocking is the creation of a fake object that simulates the behavior of a real object in controlled ways.
Multiple Choice: Which of the following is used to raise an exception? A) throw B) raise C) error D) except
B) raise
What is ‘list indexing’?
List indexing is the process of accessing an element of a list using its position or index.
True or False: Python is a statically typed language.
False
Fill in the blank: The __________ function is used to convert a string to an integer.
int
What is ‘method overriding’?
Method overriding is the process of defining a method in a derived class that already exists in the base class.
Define ‘bytecode’.
Bytecode is an intermediate representation of Python source code that is executed by the Python virtual machine.
Multiple Choice: Which of the following is used to create a virtual environment? A) venv B) virtualenv C) env C) All of the above
C) All of the above
What is ‘scope’ in Python?
Scope refers to the visibility of variables and functions in certain parts of the code.
True or False: ‘Comprehensions’ in Python can be used for lists, sets, and dictionaries.
True
Fill in the blank: The __________ method is used to add an item to a list.
append
What is ‘thread safety’?
Thread safety is a property of a program that guarantees safe execution by multiple threads at the same time.
Define ‘closure’.
A closure is a function that retains access to its lexical scope, even when the function is executed outside that scope.
Multiple Choice: Which of the following keywords is used to create a loop? A) loop B) iterate C) for D) repeat
C) for
What is ‘f-string’ in Python?
An f-string is a string literal that is prefixed with ‘f’ and allows for embedding expressions inside string literals.
True or False: The ‘else’ clause can be used with loops in Python.
True
Fill in the blank: To create a new Python file, the extension used is __________.
.py
What is ‘Pythonic’?
Pythonic refers to code that follows the conventions and idioms of the Python programming language.
Define ‘web scraping’.
Web scraping is the process of extracting data from websites using programming.
Multiple Choice: Which of the following is a valid way to define a function? A) function myFunc() B) def myFunc() C) create myFunc() D) func myFunc()
B) def myFunc()
What is ‘flask’ in Python?
Flask is a lightweight WSGI web application framework for Python.
True or False: Python supports multiple inheritance.
True
Fill in the blank: The __________ function is used to get the length of a list.
len
What is ‘data serialization’?
Data serialization is the process of converting an object into a format that can be easily stored or transmitted.
Define ‘API endpoint’.
An API endpoint is a specific URL where an API can be accessed by a client application.
Multiple Choice: Which of the following is used for creating a virtual environment? A) pip B) venv C) python D) all of the above
D) all of the above
What is ‘session management’?
Session management is the process of maintaining the state of a user across multiple requests in web applications.
True or False: ‘yield’ is used in Python to return a value from a function.
False
Fill in the blank: The __________ operator is used to concatenate strings in Python.
+