Quizzes

Python quizzes

Choose a quiz and test your understanding of a focused concept.

Does Python Have a Ternary Conditional Operator? Quiz on Python Conditional Expressions

Test your understanding of Python conditional expressions, ternary-like syntax, common mistakes, and real-world usage.

How to Access the Index in a Python for Loop Quiz

Test your understanding of using enumerate() to access indexes in Python for loops, avoid common mistakes, and format output clearly.

How to Check if a File Exists in Python Without Exceptions Quiz

Test your understanding of checking file existence in Python using os.path and pathlib without try/except.

How to Create Nested Directories in Python with os.makedirs and Path.mkdir Quiz

Learn how to create directories and missing parent folders in Python using os.makedirs() and Path.mkdir().

How to Execute System Commands in Python Quiz

Test your understanding of running system commands in Python with subprocess.run(), output capture, shell safety, and common pitfalls.

How to Flatten a List of Lists in Python Quiz

Test your Python knowledge of flattening a list of lists using comprehensions, extend(), and itertools.chain.from_iterable().

How to Merge Two Dictionaries in Python Quiz

Test your understanding of merging Python dictionaries with `|`, unpacking, and `update()`, including overwrite rules and common mistakes.

Python __name__ == "__main__" Quiz: Direct Run vs Import

Test your understanding of Python's __name__ == "__main__" pattern, imports, top-level code, and clean script organization.

Python `yield` Keyword Quiz: Generators, Laziness, and Tree Traversal

Test your understanding of Python `yield`, generator functions, lazy iteration, and how generators behave in traversal code.

What Are Metaclasses in Python? Quiz for Beginners

Test your understanding of Python metaclasses, type, class creation, common mistakes, and real-world use cases with this beginner quiz.