Learn
Practice
Projects
Free datasets
Resources
Toolkit
Pricing
Log in
Start free
Loading…
Python Quiz (200 Questions)
← All topics
Python Quiz (200 Questions)
200 exercises
·
10 free
01
What Is Python Primarily Known As?
Free
→
02
How Do You Start The Python Interactive Interpreter (REPL) From A Terminal?
Free
→
03
In Python, How Are Code Blocks Defined?
Free
→
04
How Do You Display "Hello World" In Python?
Free
→
05
Which Extension Is Commonly Used For Python Files?
Free
→
06
How Do You Write A Single-Line Comment In Python?
Free
→
07
Python 3 Print Function Requires What Around The Text To Print?
Free
→
08
Python Code Indentation Typically Uses How Many Spaces?
Free
→
09
Which Function Retrieves Input From The User In Python 3?
Free
→
10
Which Command Do You Use To Run A Python Script File From The Terminal?
Free
→
11
Which Of The Following Is NOT A Built-In Data Type In Python?
Locked
→
12
Strings In Python Are:
Locked
→
13
Which Function Gives The Data Type Of A Variable In Python?
Locked
→
14
In Python, Variables Are:
Locked
→
15
Which Built-In Constant Represents The Absence Of A Value?
Locked
→
16
Booleans In Python Are Represented By Which Keywords?
Locked
→
17
Which Of The Following Is Immutable?
Locked
→
18
To Convert A String '123' To An Integer:
Locked
→
19
The Identity Operator 'Is' Checks If:
Locked
→
20
Which Function Gives The Memory Address Of An Object?
Locked
→
21
Which Operator Is Used For Exponentiation In Python?
Locked
→
22
The Integer Division Operator In Python Is:
Locked
→
23
The 'In' Operator Checks:
Locked
→
24
Which Operator Has Higher Precedence: * Or + ?
Locked
→
25
The Modulo Operator % Does What?
Locked
→
26
X += 5 Is Equivalent To:
Locked
→
27
The 'Not' Operator In Python Is Used For:
Locked
→
28
Is' Checks Object Identity, While '==' Checks:
Locked
→
29
Bitwise AND Operator Is Represented By:
Locked
→
30
Which Is True About Short-Circuit Evaluation In Python?
Locked
→
31
Which Keyword Introduces A Conditional Block?
Locked
→
32
Elif' Is Used In Python To:
Locked
→
33
A 'For' Loop In Python Typically Iterates Over:
Locked
→
34
The 'While' Loop Continues Until:
Locked
→
35
Break' In A Loop Does What?
Locked
→
36
Continue' In A Loop Does What?
Locked
→
37
Range(5)' Generates:
Locked
→
38
The 'Else' Clause On A Loop Executes When:
Locked
→
39
Pass' Statement Is Used For:
Locked
→
40
Which Is Correct For An If-Else Block?
Locked
→
41
How Do You Define A Function In Python?
Locked
→
42
If A Function Doesn't Have A Return Statement, It Returns:
Locked
→
43
Default Function Parameters Are Specified Using:
Locked
→
44
*Args In A Function Definition Means:
Locked
→
45
**Kwargs In A Function Definition Means:
Locked
→
46
Variables Defined Inside A Function Are By Default:
Locked
→
47
The 'Global' Keyword Is Used To:
Locked
→
48
Return' Keyword In A Function Does What?
Locked
→
49
Recursive Functions Are Functions That:
Locked
→
50
Lambda Functions In Python Are:
Locked
→
51
How Do You Import A Module Named 'Math' In Python?
Locked
→
52
What Does `From Math Import Sqrt` Do?
Locked
→
53
`__name__ == "__main__"` Is Used To:
Locked
→
54
Where Does Python Look For Modules By Default?
Locked
→
55
A Package Is Defined By The Presence Of:
Locked
→
56
`Pip` Is Used To:
Locked
→
57
Virtual Environments (Venv) Are Used To:
Locked
→
58
`Dir(Module)` Function Returns:
Locked
→
59
Using `Import Module As M` Does What?
Locked
→
60
`Help(Module)` Function:
Locked
→
61
Lists In Python Are:
Locked
→
62
Tuples In Python Are:
Locked
→
63
Which Method Adds An Item To The End Of A List?
Locked
→
64
Negative Indexing In Lists Means:
Locked
→
65
List Slicing Syntax `List[Start:End]` Returns:
Locked
→
66
`List.sort()` Method Does What?
Locked
→
67
To Quickly Create A List Of Squares, You Can Use:
Locked
→
68
Tuples Can Be Used For:
Locked
→
69
To Unpack A Tuple (X, Y) Into Variables A And B:
Locked
→
70
`Enumerate(List)` Is Often Used To:
Locked
→
71
A Dictionary In Python Is:
Locked
→
72
A Set In Python Is:
Locked
→
73
To Get All Keys Of A Dictionary As A List (In Python 3.X You Get A View), You Use:
Locked
→
74
To Add A Key-Value Pair To A Dictionary:
Locked
→
75
Which Data Structure Is Best For Checking Membership Quickly?
Locked
→
76
Dictionary.get(Key) Method Does What If Key Not Found?
Locked
→
77
Set Operations Like Union Or Intersection Are Available As:
Locked
→
78
Keys In A Dictionary Must Be:
Locked
→
79
`Pop` Method On A Dictionary Does What?
Locked
→
80
To Remove Duplicates From A List, You Could Convert It To A:
Locked
→
81
How Do You Get A Substring From Index 2 To 5 In A String S?
Locked
→
82
Which Method Returns A String In Uppercase?
Locked
→
83
`S.strip()` Does What?
Locked
→
84
`S.find('X')` Returns:
Locked
→
85
`S.split()` Without Arguments Splits A String By:
Locked
→
86
`Join()` Method Is Used To:
Locked
→
87
F-Strings Are Defined Using:
Locked
→
88
`Str.upper()` Returns:
Locked
→
89
`In` Operator On A String Checks For:
Locked
→
90
`Str.replace(Old, New)` Returns:
Locked
→
91
How Do You Open A File In Python For Reading?
Locked
→
92
The `With` Statement Is Used With Files To:
Locked
→
93
File.read() Without Arguments Reads:
Locked
→
94
File.readline() Reads:
Locked
→
95
File.write("Hello") Does What?
Locked
→
96
R+' Mode In Open Means:
Locked
→
97
To Ensure Safe File Handling Use:
Locked
→
98
To Read All Lines Of A File Into A List:
Locked
→
99
`With Open("Data.txt", "W") As F:` Does What If Data.txt Exists?
Locked
→
100
Binary Mode Is Indicated By:
Locked
→
101
How Do You Define A Class In Python?
Locked
→
102
The __init__ Method In A Class:
Locked
→
103
Self' Parameter In Methods Refers To:
Locked
→
104
To Create An Instance Of A Class MyClass:
Locked
→
105
Class Attributes Are:
Locked
→
106
Instance Attributes Are Usually Set In:
Locked
→
107
Inheritance In Python Is Defined By:
Locked
→
108
`Isinstance(Obj, Class)` Returns True If:
Locked
→
109
Encapsulation In Python Is Done By:
Locked
→
110
OOP Stands For:
Locked
→
111
Multiple Inheritance Means:
Locked
→
112
The `Super()` Function Is Used To:
Locked
→
113
`__str__` And `__repr__` Methods Are Special Methods Used For:
Locked
→
114
@Property Decorator Is Used To:
Locked
→
115
Static Methods In Python Are Defined Using:
Locked
→
116
An Abstract Base Class (ABC) Requires Importing:
Locked
→
117
An Abstract Method Must Be:
Locked
→
118
Polymorphism Refers To:
Locked
→
119
Operator Overloading Is Done By:
Locked
→
120
Design Patterns In OOP Are:
Locked
→
121
Try/Except Block Is Used For:
Locked
→
122
If No Exception Occurs In A Try Block:
Locked
→
123
`Raise` Keyword Does What?
Locked
→
124
Finally Block Executes:
Locked
→
125
Custom Exceptions Are Created By:
Locked
→
126
Assert Statement Is Used To:
Locked
→
127
Except Exception As E:
Locked
→
128
Avoiding Bare Except (I.e. Except:) Is Recommended Because:
Locked
→
129
Else Clause In Try-Except-Else Runs If:
Locked
→
130
Try-Except-Finally Structure Ensures:
Locked
→
131
An Iterator Is An Object That:
Locked
→
132
`Iter()` Function Returns:
Locked
→
133
`__next__()` Method In An Iterator Raises What When No More Items?
Locked
→
134
A Generator Function Is Defined Using:
Locked
→
135
Generator Expressions Look Like List Comprehensions But Use:
Locked
→
136
Generators Are Memory Efficient Because:
Locked
→
137
Infinite Generators Must Have A Condition To Stop Or They'll:
Locked
→
138
Yield From' Is Used To:
Locked
→
139
StopIteration Is Raised By __next__() To:
Locked
→
140
Itertools Module Provides:
Locked
→
141
A Decorator In Python Is Applied Using:
Locked
→
142
Decorators Take A Function As Input And:
Locked
→
143
`@Property` Is A Built-In Decorator To Create:
Locked
→
144
Context Managers Use Which Methods?
Locked
→
145
Using `With Open('File') As F:` Is An Example Of:
Locked
→
146
The `Contextlib` Module Provides:
Locked
→
147
Decorators Can Be Used To:
Locked
→
148
Multiple Decorators On One Function Are Applied:
Locked
→
149
The `With` Statement Calls __enter__ When:
Locked
→
150
The Main Benefit Of Context Managers Is:
Locked
→
151
Map(Function, Iterable) Returns:
Locked
→
152
Filter(Function, Iterable) Keeps Elements Where:
Locked
→
153
Reduce(Function, Iterable) In Functools Module Does What?
Locked
→
154
A Lambda Function Is Defined Using:
Locked
→
155
List Comprehensions Provide A Concise Way To:
Locked
→
156
Any() Returns True If:
Locked
→
157
All() Returns True If:
Locked
→
158
Inline If In Comprehensions Allow:
Locked
→
159
Functions As First-Class Objects Mean:
Locked
→
160
Functional Style Is Often Beneficial Because:
Locked
→
161
`Datetime` Module Provides:
Locked
→
162
`Os` Module Is Commonly Used For:
Locked
→
163
`Sys.argv` Is Used To:
Locked
→
164
`Math` Module Provides:
Locked
→
165
`Random` Module Is Used To:
Locked
→
166
`Json` Module Allows:
Locked
→
167
`Re` Module Is For:
Locked
→
168
`Collections` Module Provides:
Locked
→
169
`Argparse` Module Helps In:
Locked
→
170
`Subprocess` Module Is Used To:
Locked
→
171
A Virtual Environment In Python Is Created Using:
Locked
→
172
Activating A Virtual Env On Unix Is Done By:
Locked
→
173
`Requirements.txt` File Lists:
Locked
→
174
`Pip Install -R Requirements.txt` Does What?
Locked
→
175
`Pip Freeze` Outputs:
Locked
→
176
Virtual Environments Help By:
Locked
→
177
Pip Is A Package Manager For:
Locked
→
178
Upgrading A Package With Pip:
Locked
→
179
Conda Or Poetry Are:
Locked
→
180
Dependency Conflicts Occur When:
Locked
→
181
Unittest Is:
Locked
→
182
A Unittest Test Case Is Created By Subclassing:
Locked
→
183
Common Assertion Method In Unittest Is:
Locked
→
184
Pytest Allows Tests To Be Simple Functions That:
Locked
→
185
Fixtures In Pytest Are Used To:
Locked
→
186
Mocking In Tests Is Used To:
Locked
→
187
Running Subset Of Tests In Pytest Can Be Done By:
Locked
→
188
`AssertRaises` In Unittest Is Used To:
Locked
→
189
Coverage Tools Measure:
Locked
→
190
TDD (Test-Driven Development) Means:
Locked
→
191
GIL (Global Interpreter Lock) In CPython Affects:
Locked
→
192
`Multiprocessing` Module Allows:
Locked
→
193
Async/Await Syntax Is Used For:
Locked
→
194
Parallelizing CPU-Bound Tasks Can Be Improved By:
Locked
→
195
Profiling Code Helps By:
Locked
→
196
`CProfile` Is A Tool For:
Locked
→
197
Partitioning Large Datasets Can Help By:
Locked
→
198
Caching Results Can Improve Performance By:
Locked
→
199
`Functools.lru_cache` Decorator Can Be Used To:
Locked
→
200
Async IO Helps When:
Locked
→