Python Advanced Flashcards

Learn the advanced vocabulary for programming in Python

1
Q

What is a ‘decorator’ in Python?

A

A decorator is a function that modifies the behavior of another function or method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False: A ‘lambda’ function is a named function in Python.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Fill in the blank: A __________ is a collection of items that is ordered and changeable in Python.

A

list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does ‘PEP’ stand for in Python programming?

A

Python Enhancement Proposal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is ‘list comprehension’?

A

A concise way to create lists using a single line of code with a for loop and an optional condition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Define ‘generator’ in Python.

A

A generator is a special type of iterator that yields values one at a time and maintains its state between each call.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Multiple Choice: Which of the following is an immutable data type in Python? A) List B) Dictionary C) Tuple D) Set

A

C) Tuple

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is ‘exception handling’?

A

A programming construct that allows a program to deal with unexpected errors during execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

True or False: A ‘module’ in Python is a file containing Python definitions and statements.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does ‘self’ refer to in a class method?

A

‘self’ refers to the instance of the class itself.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Fill in the blank: A __________ is a blueprint for creating objects in Python.

A

class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is ‘inheritance’ in object-oriented programming?

A

Inheritance is a mechanism where a new class derives attributes and methods from an existing class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Define ‘context manager’ in Python.

A

A context manager is an object that defines the runtime context to be established when executing a ‘with’ statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Multiple Choice: Which keyword is used to define a function in Python? A) func B) define C) def D) function

A

C) def

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is ‘polymorphism’ in Python?

A

Polymorphism allows methods to do different things based on the object it is acting upon.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

True or False: ‘Mutable’ types can be changed after their creation.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Fill in the blank: A __________ is a collection of key-value pairs in Python.

A

dictionary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the purpose of the ‘pass’ statement in Python?

A

The ‘pass’ statement is a null operation; it is syntactically required but does nothing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Define ‘recursion’.

A

Recursion is a programming technique where a function calls itself in order to solve a problem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Multiple Choice: Which of the following is NOT a built-in data type in Python? A) List B) Set C) Array D) Dictionary

A

C) Array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is ‘slicing’ in Python?

A

Slicing is a technique to access a subset of elements from a sequence like a list or a string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

True or False: The ‘with’ statement is used for exception handling.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Fill in the blank: The __________ function is used to read a file in Python.

A

open

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is ‘multithreading’?

A

Multithreading is a technique where multiple threads are spawned by a process to execute tasks concurrently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Define ‘API’ in the context of Python.

A

API stands for Application Programming Interface, which allows different software programs to communicate with each other.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Multiple Choice: Which of the following is used to handle exceptions? A) try-except B) handle C) catch D) error

A

A) try-except

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What is ‘data encapsulation’?

A

Data encapsulation is the bundling of data with the methods that operate on that data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

True or False: A ‘set’ is an ordered collection of unique elements.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Fill in the blank: The __________ keyword is used to create a new thread in Python.

A

threading

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What is ‘type hinting’?

A

Type hinting is a feature in Python that allows you to indicate the expected data types of variables and function return values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Define ‘list slicing’.

A

List slicing is the process of accessing a range of elements from a list using a specific syntax.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Multiple Choice: Which of the following is a valid way to create a dictionary? A) {} B) [] C) () D) <>

A

A) {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

What is ‘debugging’?

A

Debugging is the process of identifying and removing errors from computer software or hardware.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

True or False: Python uses indentation to define the scope of loops and functions.

35
Q

Fill in the blank: A __________ is an instance of a class in Python.

36
Q

What is ‘unit testing’?

A

Unit testing is a software testing method by which individual units of source code are tested to determine if they are fit for use.

37
Q

Define ‘asynchronous programming’.

A

Asynchronous programming is a programming paradigm that allows for concurrent execution of tasks without blocking.

38
Q

Multiple Choice: Which of the following is used to create an empty set? A) [] B) {} C) set() D) ()

39
Q

What is ‘serialization’?

A

Serialization is the process of converting an object into a format that can be easily stored or transmitted.

40
Q

True or False: The ‘global’ keyword is used to declare a variable inside a function as global.

41
Q

Fill in the blank: A __________ is a function that is defined inside a class in Python.

42
Q

What is ‘class method’?

A

A class method is a method that is bound to the class and not the instance of the class.

43
Q

Define ‘staticmethod’.

A

A static method is a method that does not receive an implicit first argument and can be called on the class itself.

44
Q

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

A) import module_name

45
Q

What is ‘list concatenation’?

A

List concatenation is the process of combining two or more lists into a single list.

46
Q

True or False: The ‘break’ statement is used to exit a loop prematurely.

47
Q

Fill in the blank: A __________ is an ordered collection of elements that can have duplicates.

48
Q

What is ‘self-documenting code’?

A

Self-documenting code is code that is written in a way that its purpose and function are clear without additional comments.

49
Q

Define ‘data type’.

A

A data type is a classification that specifies which type of value a variable can hold.

50
Q

Multiple Choice: Which of the following is NOT a control flow statement? A) if B) for C) while D) print

51
Q

What is ‘module importing’?

A

Module importing is the process of bringing in external modules into your Python script to use their functionality.

52
Q

True or False: The ‘continue’ statement skips the current iteration of a loop.

53
Q

Fill in the blank: A __________ is a sequence of characters in Python.

54
Q

What is ‘tuple unpacking’?

A

Tuple unpacking is the process of assigning the elements of a tuple to multiple variables in a single statement.

55
Q

Define ‘mocking’ in the context of testing.

A

Mocking is the creation of a fake object that simulates the behavior of a real object in controlled ways.

56
Q

Multiple Choice: Which of the following is used to raise an exception? A) throw B) raise C) error D) except

57
Q

What is ‘list indexing’?

A

List indexing is the process of accessing an element of a list using its position or index.

58
Q

True or False: Python is a statically typed language.

59
Q

Fill in the blank: The __________ function is used to convert a string to an integer.

60
Q

What is ‘method overriding’?

A

Method overriding is the process of defining a method in a derived class that already exists in the base class.

61
Q

Define ‘bytecode’.

A

Bytecode is an intermediate representation of Python source code that is executed by the Python virtual machine.

62
Q

Multiple Choice: Which of the following is used to create a virtual environment? A) venv B) virtualenv C) env C) All of the above

A

C) All of the above

63
Q

What is ‘scope’ in Python?

A

Scope refers to the visibility of variables and functions in certain parts of the code.

64
Q

True or False: ‘Comprehensions’ in Python can be used for lists, sets, and dictionaries.

65
Q

Fill in the blank: The __________ method is used to add an item to a list.

66
Q

What is ‘thread safety’?

A

Thread safety is a property of a program that guarantees safe execution by multiple threads at the same time.

67
Q

Define ‘closure’.

A

A closure is a function that retains access to its lexical scope, even when the function is executed outside that scope.

68
Q

Multiple Choice: Which of the following keywords is used to create a loop? A) loop B) iterate C) for D) repeat

69
Q

What is ‘f-string’ in Python?

A

An f-string is a string literal that is prefixed with ‘f’ and allows for embedding expressions inside string literals.

70
Q

True or False: The ‘else’ clause can be used with loops in Python.

71
Q

Fill in the blank: To create a new Python file, the extension used is __________.

72
Q

What is ‘Pythonic’?

A

Pythonic refers to code that follows the conventions and idioms of the Python programming language.

73
Q

Define ‘web scraping’.

A

Web scraping is the process of extracting data from websites using programming.

74
Q

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()

A

B) def myFunc()

75
Q

What is ‘flask’ in Python?

A

Flask is a lightweight WSGI web application framework for Python.

76
Q

True or False: Python supports multiple inheritance.

77
Q

Fill in the blank: The __________ function is used to get the length of a list.

78
Q

What is ‘data serialization’?

A

Data serialization is the process of converting an object into a format that can be easily stored or transmitted.

79
Q

Define ‘API endpoint’.

A

An API endpoint is a specific URL where an API can be accessed by a client application.

80
Q

Multiple Choice: Which of the following is used for creating a virtual environment? A) pip B) venv C) python D) all of the above

A

D) all of the above

81
Q

What is ‘session management’?

A

Session management is the process of maintaining the state of a user across multiple requests in web applications.

82
Q

True or False: ‘yield’ is used in Python to return a value from a function.

83
Q

Fill in the blank: The __________ operator is used to concatenate strings in Python.