PCEP exam prep (python)

211 flashcardsby spartacus
Study these flashcardsFree · spaced repetition · iPhone, Android, Mac & web

All cards

1
What is the correct order of the Python execution model?
  • Source code to Bytecode to Python Virtual Machine (PVM)
2
What is the result of the expression 2 ** 3 ** 2 based on operator associativity?
512
3
Which built-in function returns the unique integer representing the memory address of an object?
id()
4
How is the integer value thirteen represented as a hexadecimal literal in Python?
0x0D
5
What is the result of the bitwise AND (&) operation between 10 (binary 1010) and 12 (binary 1100)?
8
6
What is the term for a high-level language that is translated into machine code at runtime by another program?
Interpreted language
7
What is the name of the official document that provides guidelines and best practices for writing Python code?
PEP 8
8
Which component of the Python execution model is responsible for converting bytecode into machine-specific instructions?
Python Virtual Machine (PVM)
9
In Python's exception hierarchy, what is the top-level base class from which almost all exceptions are derived?
BaseException
10
What is the term for a value that is written exactly as it's meant to be interpreted, such as a number or a string?
Literal
11
What is the term for a programming language where the source code is executed by another program without prior compilation to machine code?
Interpreted language
12
Who is the original creator of the Python programming language?
Guido van Rossum
13
What is the name of the default software implementation of the Python language?
CPython
14
What is the file extension for a compiled Python bytecode file?
.pyc
15
What is the term for the set of rules that defines how a Python program is written and interpreted?
Syntax
16
Which Python philosophy, summarized in PEP 20, emphasizes that 'Explicit is better than implicit'?
The Zen of Python
17
What is the term for a specific location in memory used to store data that can be changed during execution?
Variable
18
Which type of instruction is NOT executed by the Python interpreter and is used for documentation?
Comment
19
What is the term for a word that is reserved by the Python language for its own use and cannot be used as a variable name?
Keyword
20
Which character is used to start a single-line comment in Python?
#
21
What is the term for the physical distance from the left margin used to define the structure of code blocks?
Indentation
22
In the PCEP syllabus, what is the term for a literal that represents a sequence of characters?
String
23
Which type of error occurs when the interpreter cannot understand a line of code because it violates language rules?
Syntax Error
24
What is the term for an error that occurs while the program is running, such as dividing by zero?
Runtime Error
25
What is the term for the period of time during which a program is being executed?
Runtime
26
What is the binary base value used for 'octal' literals in Python?
8
27
What is the term for a decimal number that contains a fractional part?
Floating-point number
28
Which keyword is used to return a value from a function?
return
29
How many spaces are recommended by PEP 8 for a single level of indentation?
4
30
What is the term for an operation that combines two strings into one?
Concatenation
31
Which arithmetic operator is used for exponentiation?
**
32
What is the term for the order in which individual statements or instructions are executed?
Control Flow
33
Which conditional statement is used to check multiple expressions for Truth only if the previous ones were False?
elif
34
What is the term for a loop that continues to execute as long as a specified condition remains True?
while loop
35
What is the term for a loop that iterates over a sequence of elements?
for loop
36
Which keyword is used to immediately exit a loop regardless of the condition?
break
37
What is the term for an object whose value can be modified after it is created?
Mutable
38
What is the term for an object whose value cannot be changed after it is created?
Immutable
39
In Python's exception hierarchy, which class is the parent of LookupError?
Exception
40
Which specific exception is raised when a script is interrupted by the user, usually by pressing Ctrl+C?
KeyboardInterrupt
41
What is the term for the process of identifying and fixing errors in a program?
Debugging
42
Which built-in function is used to take input from a user via the console?
input()
43
What is the term for a collection of pre-written code that can be imported into a script?
Module
44
Which keyword is used to bring an external module into the current namespace?
import
45
What is the term for a unique name that represents a variable, function, or class?
Identifier
46
What is the term for the area of a program where a variable is recognized and can be accessed?
Scope
47
What is the term for a variable defined inside a function that cannot be accessed outside of it?
Local variable
48
What is the term for a variable defined at the top level of a script that is accessible everywhere?
Global variable
49
Which keyword is used inside a function to modify a variable defined outside that function?
global
50
Which data structure is an ordered, mutable collection of elements?
List
51
Which data structure is an ordered, immutable collection of elements?
Tuple
52
Which data structure is an unordered collection of key-value pairs?
Dictionary
53
What is the term for the value used to look up data in a dictionary?
Key
54
Which built-in function returns a sequence of numbers, often used in for loops?
range()
55
What is the result of a comparison operator, such as 'greater than' or 'equal to'?
Boolean value
56
What is the term for a function that is defined as part of a class?
Method
57
In the hierarchy, which exception is the parent of IndexError and KeyError?
LookupError
58
What is the term for the process of converting a value from one data type to another?
Typecasting
59
What is the term for the specific way the computer stores and represents a kind of data, like an 'int' or 'str'?
Data Type
60
Which PEP document describes the 'Zen of Python'?
PEP 20
61
What is the term for a block of code that is only executed when it is called?
Function
62
What is the term for the values passed into a function when it is called?
Arguments
63
What is the term for the variables listed in the function definition?
Parameters
64
What is the term for a function that does not have a name?
Lambda function
65
Can a Python list contain elements of different data types?
Yes
66
Which data type is used to represent the absence of a value or a null value?
NoneType
67
What is the term for a literal that is either True or False?
Boolean literal
68
What is the name of the function used to find out the data type of an object?
type()
69
What is the term for a sequence of characters enclosed in triple quotes?
Docstring
70
Which built-in function is used to convert a string or float to an integer?
int()
71
In Python, is the identifier 'MyVariable' the same as 'myvariable'?
No
72
What is the maximum length of an identifier in Python?
Unlimited
73
Which character cannot be the first character of a Python identifier?
A digit
74
What is the term for an operator that requires two operands?
Binary operator
75
What is the term for an operator that requires only one operand?
Unary operator
76
Which arithmetic operator returns the remainder of a division?
%
77
What is the term for the process of repeating a set of instructions?
Iteration
78
In a 'for' loop, what is the term for the variable that takes the value of the item inside the iterable?
Control variable
79
What is the term for a list that is contained inside another list?
Nested list
80
Which method is used to remove all elements from a list?
clear()
81
Which method is used to remove an element at a specific index from a list?
pop()
82
Which method is used to find the index of the first occurrence of a value in a list?
index()
83
What is the term for the shorthand way of creating a list based on an existing iterable?
List comprehension
84
Can a dictionary key be a mutable object, such as a list?
No
85
What is the built-in function used to sort a list without modifying the original list?
sorted()
86
What is the term for a script that is intended to be run directly?
Program
87
In a package, what is the name of the file that used to be required to treat the directory as a package?
init.py
88
Which keyword is used to create an alias for a module when importing it?
as
89
What is the term for the situation where two different modules have the same name?
Name clash
90
Which built-in function returns a list of all valid attributes and methods of an object?
dir()
91
What is the term for an error that occurs when a variable is used before it has been assigned a value?
NameError
92
Which exception is raised when an operation or function is applied to an object of inappropriate type?
TypeError
93
Which exception is raised when a built-in operation or function receives an argument with the right type but an inappropriate value?
ValueError
94
Which exception is raised when code tries to access a local variable before it is defined?
UnboundLocalError
95
What is the term for a block of code that handles an exception?
Exception handler
96
Which keyword is used to manually trigger or throw an exception?
raise
97
What is the term for a value that cannot be changed by the program during its execution?
Constant
98
What is the term for the process of combining two or more tuples into one?
Tuple concatenation
99
Which function is used to get the user's current directory or environment information in a script?
The os module
100
What is the term for the specific order in which operators are evaluated in an expression?
Precedence
101
What is the term for an expression that evaluates to either True or False?
Condition
102
Which logical operator returns True only if both operands are True?
and
103
Which logical operator returns True if at least one operand is True?
or
104
Which logical operator reverses the Boolean value of its operand?
not
105
What is the term for a piece of data that is passed back to the caller of a function?
Return value
106
What is the term for a function that calls itself?
Recursive function
107
What is the term for a set of data that can be iterated over, like a list or string?
Iterable
108
What is the term for an object that represents a stream of data and can be used in a loop?
Iterator
109
Which keyword is used to provide a "do-nothing" placeholder in a code block?
pass
110
What is the term for the Python repository where most third-party modules are hosted?
PyPI
111
(Language Fundamentals & Architecture) What is the term for a language that requires a special program to execute the source code directly?
Interpreted language
112
(Language Fundamentals & Architecture) Does the Python Virtual Machine (PVM) execute source code or bytecode?
Bytecode
113
(Language Fundamentals & Architecture) What is the primary advantage of Python being a "Platform Independent" language?
Code can run on any OS with a compatible interpreter
114
(Language Fundamentals & Architecture) In the CPython implementation, what tool is used to manage memory through reference counting?
Garbage Collector
115
(Language Fundamentals & Architecture) What is the result of a "Logical Error" in a program?
The program runs but produces incorrect results
116
(Language Fundamentals & Architecture) What do we call the formal set of rules for combining symbols to create a correctly structured program?
Syntax
117
(Language Fundamentals & Architecture) Which standard allows Python to handle characters from almost every writing system in the world?
Unicode
118
(Language Fundamentals & Architecture) What is the term for the "canonical" version of Python that serves as the reference for all other versions?
CPython
119
(Language Fundamentals & Architecture) What is the term for a collection of tools, libraries, and best practices that make up the Python ecosystem?
Distribution
120
(Language Fundamentals & Architecture) What is the name of the tool used to install and manage additional Python packages?
pip
121
(Identifiers, Keywords, and Literals) In Python 3.x, are keywords case-sensitive?
Yes
122
(Identifiers, Keywords, and Literals) Which character is used as a "throwaway" or "dummy" identifier by convention?
_ (Underscore)
123
(Identifiers, Keywords, and Literals) Can a Python keyword be used as a function name?
No
124
(Identifiers, Keywords, and Literals) What is the term for a literal that represents a fractional number using scientific notation?
E-notation (e.g., 2e3)
125
(Identifiers, Keywords, and Literals) Which base is used when an integer literal starts with 0o?
Octal (Base 8)
126
(Identifiers, Keywords, and Literals) How many keywords are there approximately in Python 3.13?
Around 35-40
127
(Identifiers, Keywords, and Literals) What is the name for the 'none' value in a database context compared to Python?
SQL NULL
128
(Identifiers, Keywords, and Literals) What is the name for a sequence of bytes used to store raw binary data in Python?
bytes
129
(Identifiers, Keywords, and Literals) Can a variable name start with an underscore?
Yes
130
(Identifiers, Keywords, and Literals) What is the term for a hard-coded value in a program?
Literal
131
(Control Flow & Logic Theory) In a conditional statement, what is the term for the code that runs only if the condition is True?
Suite (or block)
132
(Control Flow & Logic Theory) What is the technical term for the decision-making process in a program?
Selection
133
(Control Flow & Logic Theory) What is the term for a loop that never ends because the exit condition is never met?
Infinite loop
134
(Control Flow & Logic Theory) In a for loop, what happens to the control variable after the loop finishes?
It retains its last assigned value
135
(Control Flow & Logic Theory) Which keyword is used to skip the current code block and move to the next iteration?
continue
136
(Control Flow & Logic Theory) What is the term for a loop placed inside another loop?
Nested loop
137
(Control Flow & Logic Theory) Which logical operator has the lowest precedence: and, or, or not?
or
138
(Control Flow & Logic Theory) What is the term for an expression that Python evaluates to see if it is "True-like" or "False-like"?
Truthy and Falsy
139
(Control Flow & Logic Theory) What is the default Boolean value of an empty list?
False
140
(Control Flow & Logic Theory) What is the term for "short-circuiting" in logical expressions?
Stopping evaluation as soon as the result is certain
141
(Operators & Expressions) What is the associativity of the exponentiation operator **?
Right-to-left
142
(Operators & Expressions) What is the associativity of most arithmetic operators like + and -?
Left-to-right
143
(Operators & Expressions) What is the name of the // operator?
Floor division
144
(Operators & Expressions) In Python, what is the type of the result of any operation involving a float and an integer?
float
145
(Operators & Expressions) Which operator is used to check if a value exists within a sequence?
in
146
(Operators & Expressions) What is the term for a single value or variable used with an operator?
Operand
147
(Operators & Expressions) What is the term for an operator that appears between its two operands?
Infix operator
148
(Operators & Expressions) Which operator is used to perform a bitwise XOR?
^
149
(Operators & Expressions) What is the term for the "reversing" of bits in bitwise logic?
Bitwise NOT
150
(Operators & Expressions) Which comparison operator is used to check for inequality?
!=
151
(Data Structures (Lists & Tuples)) What is the term for the position of an element within a list?
Index
152
(Data Structures (Lists & Tuples)) What is the starting index of any sequence in Python?
0
153
(Data Structures (Lists & Tuples)) What is the term for a list that contains other lists as elements?
Multi-dimensional list
154
(Data Structures (Lists & Tuples)) Which list method adds an element at a specific position?
insert()
155
(Data Structures (Lists & Tuples)) Which list method removes and returns the last element?
pop()
156
(Data Structures (Lists & Tuples)) What is the term for creating a new list from a subset of an existing list using a colon?
Slicing
157
(Data Structures (Lists & Tuples)) In a slice [start:end], is the end index included in the result?
No
158
(Data Structures (Lists & Tuples)) What is the term for an immutable sequence of elements?
Tuple
159
(Data Structures (Lists & Tuples)) What is the term for "unpacking" a tuple?
Assigning its values to multiple variables in one line
160
(Data Structures (Lists & Tuples)) What is the name of the function that returns the number of items in a list?
len()
161
(Data Structures (Dictionaries & Sets)) What is the term for the relationship between a key and a value in a dictionary?
Mapping
162
(Data Structures (Dictionaries & Sets)) Are dictionary keys required to be unique?
Yes
163
(Data Structures (Dictionaries & Sets)) Are dictionary values required to be unique?
No
164
(Data Structures (Dictionaries & Sets)) What is the term for a collection that is unordered and contains no duplicate elements?
Set
165
(Data Structures (Dictionaries & Sets)) Which dictionary method returns all the keys in the dictionary?
keys()
166
(Data Structures (Dictionaries & Sets)) Which dictionary method returns all the values in the dictionary?
values()
167
(Data Structures (Dictionaries & Sets)) How is an empty dictionary represented?
{}
168
(Data Structures (Dictionaries & Sets)) How is an empty set represented?
set()
169
(Data Structures (Dictionaries & Sets)) What is the term for the data type used as a key in a dictionary (must be unchangeable)?
Hashable
170
(Data Structures (Dictionaries & Sets)) What is the term for the "dictionary-like" feature in BI tools for looking up values?
Lookup Table
171
(Functions & Scoping Defaults) What is the term for a function's "signature" or "header"?
Definition
172
(Functions & Scoping Defaults) What is the term for a parameter that has a pre-assigned value in the function header?
Default parameter
173
(Functions & Scoping Defaults) What is the term for passing arguments to a function based on their name rather than their order?
Keyword arguments
174
(Functions & Scoping Defaults) What is the term for passing arguments based on their sequence in the function call?
Positional arguments
175
(Functions & Scoping Defaults) What is the term for the range of a program where a variable can be seen?
Scope
176
(Functions & Scoping Defaults) What is the keyword used to declare that a variable inside a function refers to a variable in the outer script?
global
177
(Functions & Scoping Defaults) What is the name for the special variable __name__ when a script is run directly?
main
178
(Functions & Scoping Defaults) What is the term for a function that does not return an explicit value?
None-returning function
179
(Functions & Scoping Defaults) What is the name for the hidden "namespace" where Python keeps its built-in functions?
Builtins
180
(Functions & Scoping Defaults) What is the term for the "Shadowing" of a variable?
When a local variable has the same name as a global one
181
(Exceptions & Error Handling) What is the term for a "runtime" error in Python?
Exception
182
(Exceptions & Error Handling) Which block is used to catch and handle a potential error?
except
183
(Exceptions & Error Handling) Which block contains code that should be "guarded" from errors?
try
184
(Exceptions & Error Handling) What is the term for the "path" or "history" of an error shown in the console?
Traceback
185
(Exceptions & Error Handling) Which exception is raised when using a key that doesn't exist in a dictionary?
KeyError
186
(Exceptions & Error Handling) Which exception is raised when trying to access a list index that is too large?
IndexError
187
(Exceptions & Error Handling) What is the name of the "mother" of all built-in exceptions (not counting system exits)?
Exception
188
(Exceptions & Error Handling) Which block runs only if no exceptions were raised in the try block?
else
189
(Exceptions & Error Handling) Which block runs whether an exception happened or not?
finally
190
(Exceptions & Error Handling) What is the term for "bubbling up" an error to the caller?
Exception propagation
191
(Modules, Packages, and PEPs) What is the term for a single .py file containing Python code?
Module
192
(Modules, Packages, and PEPs) What is the term for a directory containing multiple Python modules?
Package
193
(Modules, Packages, and PEPs) Which keyword is used to import only a specific part of a module?
from
194
(Modules, Packages, and PEPs) What is the name of the variable that stores the search path for modules?
sys.path
195
(Modules, Packages, and PEPs) Which PEP provides the "Style Guide for Python Code"?
PEP 8
196
(Modules, Packages, and PEPs) What is the primary goal of PEP 8?
To improve the readability of code
197
(Modules, Packages, and PEPs) According to PEP 8, should you use tabs or spaces for indentation?
Spaces
198
(Modules, Packages, and PEPs) Which PEP describes the "Zen of Python"?
PEP 20
199
(Modules, Packages, and PEPs) What is the term for "Pythonic" code?
Code that follows the idioms and philosophies of the language
200
(Modules, Packages, and PEPs) What is the term for the "Standard Library"?
The collection of modules that comes "out of the box" with Python
201
(General Theory & Final Concepts) What is the name of the integer division operator?
//
202
(General Theory & Final Concepts) What is the term for the "blueprint" used to create objects?
Class
203
(General Theory & Final Concepts) Is Python an "Object-Oriented" language?
Yes
204
(General Theory & Final Concepts) What is the term for a specific instance of a class?
Object
205
(General Theory & Final Concepts) What is the term for "Dynamic Typing"?
Variables can change types during execution
206
(General Theory & Final Concepts) What is the term for "Strong Typing"?
Python does not implicitly convert unrelated types (like string + int)
207
(General Theory & Final Concepts) What is the name for the #! line at the top of a script on Unix/Linux?
Shebang
208
(General Theory & Final Concepts) What is the term for a "bug" that doesn't stop the program but gives the wrong answer?
Logic error
209
(General Theory & Final Concepts) What is the name for the function that gives you the documentation of a module or function?
help()
210
(General Theory & Final Concepts) What is the term for the "Environment" where Python code is entered and executed immediately?
REPL (Read-Eval-Print Loop)
211
Which of the following describes the correct order of the Python execution model? A) Source code -> PVM -> Bytecode, B) Bytecode -> Source code -> PVM, C) Source code -> Bytecode -> PVM, D) PVM -> Bytecode -> Source code
C) Source code -> Bytecode -> PVM. Explanation: Python first takes the human-readable Source code and compiles it into an intermediate, platform-independent Bytecode. Finally, the Python Virtual Machine (PVM) interprets that bytecode into machine-specific instructions to execute the program.
Study all 211 cards for free