← All topics

Python Quiz (200 Questions)

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