Questions
Python questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Flatten a List of Lists in Python
Learn how to flatten a list of lists in Python using loops, comprehensions, and standard library tools with clear examples.
How to Get a Random Element from a List in Python
Learn how to randomly select an item from a Python list using beginner-friendly examples, syntax, pitfalls, and practical use cases.
How to Get an Object's Class Name in Python
Learn how to get the class name of an object in Python using __class__, type(), and __name__ with examples and common mistakes.
How to Get the Current Time in Python
Learn how to get the current time in Python using datetime and time modules with simple examples, explanations, and common mistakes.
How to Get the Last Element of a List in Python
Learn how to get the last element of a list in Python using negative indexing and length-based indexing with clear examples.
How to Get the Length of a List in Python
Learn how to get the number of elements in a Python list using len(), with examples, common mistakes, and practical use cases.
How to Get the Row Count of a Pandas DataFrame in Python
Learn how to get the number of rows in a pandas DataFrame using shape, len(), and other practical Python examples.
How to Implement a Singleton in Python: Patterns, Tradeoffs, and Pythonic Alternatives
Learn singleton implementation in Python using modules, __new__, decorators, and metaclasses, with tradeoffs and Pythonic guidance.
How to Import Python Files from a Different Folder
Learn how Python imports work across folders, packages, and project structure with clear examples and fixes for common import errors.
How to Import a Module Dynamically by Full File Path in Python
Learn how to dynamically import a Python module from a full file path using importlib, with examples, pitfalls, and practical use cases.
How to Install Python Packages from requirements.txt Using pip and a Local Directory
Learn how pip installs packages from requirements.txt and a local directory, why installs may appear to work, and how to verify them in Python.
How to Install a Specific Package Version with pip in Python
Learn how to install a specific package version with pip in Python, verify what was installed, and troubleshoot version mismatch issues.
How to Install pip on Windows for Python
Learn how to install pip on Windows, what pip does, and the safest ways to get it working for Python projects and packages.
How to Iterate Over Rows in a Pandas DataFrame in Python
Learn how to iterate over Pandas DataFrame rows in Python, understand iterrows and itertuples, and choose the right approach.
How to Limit Floats to Two Decimal Places in Python
Learn why Python floats show values like 13.949999999999999 and how to round, format, and use Decimal correctly for 2 decimal places.
How to List All Files in a Directory in Python
Learn how to list files in a directory in Python using os.listdir, os.scandir, and pathlib with practical examples and common mistakes.
How to Lowercase a String in Python
Learn how to convert a string to lowercase in Python using built-in string methods, examples, common mistakes, and practical use cases.
How to Measure Elapsed Time in Python
Learn how to measure elapsed time in Python using time, perf_counter, and timeit with simple examples and common mistakes.
How to Measure Python Program Execution Time
Learn how to measure the execution time of a full Python program using time and perf_counter with clear examples and common pitfalls.
How to Merge Two Dictionaries in a Single Expression in Python
Learn how to merge two dictionaries in Python, including single-expression syntax, overwrite rules, examples, mistakes, and best practices.