Questions
Python questions
Choose a question page, learn the concept, then test your understanding with a quiz.
@staticmethod vs @classmethod in Python Explained
Learn the difference between @staticmethod and @classmethod in Python with clear examples, use cases, mistakes, and a mini project.
Add Rows to a Pandas DataFrame in Python
Learn how to add rows to a Pandas DataFrame, why repeated row appends are slow, and when to use loc, concat, or record lists.
Call a Function by Name in a Python Module
Learn how to call a function by name in a Python module using strings, getattr, and safe patterns for dynamic function dispatch.
Catch Multiple Exceptions in One except Block in Python
Learn how to catch multiple exceptions in one Python except block using tuples, with examples, mistakes, and real-world usage.
Check Whether a Directory Exists in Python
Learn how to check whether a directory exists in Python using pathlib and os.path, including safe validation patterns and examples.
Check the Python Version Running Your Script
Learn how to check the Python interpreter version running a script with sys.version_info, sys.version, and platform in Python.
Convert Bytes to String in Python 3
Learn how to convert bytes to str in Python 3 using decode(), text mode, and proper encodings with practical examples.
Convert Pandas DataFrame Columns to Float Types
Learn how to convert pandas DataFrame columns from strings to floats using astype and to_numeric, with safe dynamic conversion patterns.
Convert Strings to Bytes in Python 3: encode() vs bytes()
Learn how to convert Python 3 strings to bytes with str.encode() and bytes(), including encodings, differences, errors, and practical examples.
Convert an Integer to a String in Python
Learn how to convert integers to strings in Python with str(), f-strings, formatting examples, common mistakes, and practical use cases.
Copying Dictionaries in Python Without Changing the Original
Learn why assigning a Python dictionary shares the same object, and how shallow and deep copies let you edit a copy safely.
Create a Dictionary from Two Lists in Python
Learn how to combine separate lists of keys and values into a Python dictionary using zip() and dict() with clear examples.
Delete a Column from a Pandas DataFrame in Python
Learn why `del df['col']` works in Pandas but `del df.col` does not, and how attribute access differs from column access in Python.
Delete an Element from a Dictionary in Python
Learn how to remove items from a Python dictionary, including how to create a new dictionary without changing the original.
Display Numbers with Leading Zeros in JavaScript
Learn how to format JavaScript numbers with leading zeros using padStart, formatting helpers, and practical examples for dates and IDs.
Does Python Have a Ternary Conditional Operator? Conditional Expressions in Python
Learn whether Python has a ternary operator, how conditional expressions work, and when to use them with clear Python examples.
Drop Rows with NaN Values in a Pandas DataFrame
Learn how to remove Pandas DataFrame rows when a specific column contains NaN, using dropna and boolean filtering with practical examples.
Find the Python site-packages Directory
Learn reliable ways to locate Python site-packages directories using sysconfig, site, pip, and virtual environments across platforms.
Fix JSONDecodeError When Parsing JSON Files in Python
Learn why Python raises JSONDecodeError for invalid JSON, how to locate syntax mistakes, and parse corrected JSON files safely.
Fix UnicodeEncodeError ASCII Codec Errors in Python BeautifulSoup
Learn why Python raises UnicodeEncodeError with web-scraped text, how non-breaking spaces cause it, and how to handle Unicode reliably.
Page 1 of 9 - 162 questions