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.
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.
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.
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.
How Python Slice Notation Works: A Beginner-Friendly Guide
Learn how Python slicing works with start, stop, and step. Understand a[x:y:z], a[:], and a[::2] with clear examples.
How to Access Environment Variables in Python
Learn how to read environment variables in Python using os.environ and os.getenv, with examples, pitfalls, and practical use cases.
How to Access the Index in a Python for Loop
Learn how to access the index in a Python for loop using enumerate(), with examples, pitfalls, and real-world use cases.
How to Add New Keys to a Python Dictionary
Learn how to add new keys to a Python dictionary, update values, avoid common mistakes, and use practical examples in real code.
How to Change Figure Size in Matplotlib (Python)
Learn how to change figure size in Matplotlib using figsize, set_size_inches, and rcParams with clear Python examples.
How to Check if a File Exists in Python Without Exceptions
Learn how to check whether a file exists in Python without try/except using os.path and pathlib with simple examples.
How to Check if a Key Exists in a Python Dictionary
Learn the best way to check whether a key exists in a Python dictionary, with examples, pitfalls, and real-world usage patterns.
How to Check if a List Is Empty in Python
Learn how to check if a list is empty in Python using idiomatic truthiness, len(), and common patterns with examples and mistakes.
How to Check if an Object Has an Attribute in Python
Learn how to check whether an object has an attribute in Python using hasattr, getattr, and safer real-world patterns.
How to Concatenate Two Lists in Python
Learn how to concatenate two lists in Python using +, extend(), unpacking, and more with examples, mistakes, and practice.
How to Copy a File in Python
Learn how to copy a file in Python using shutil, file objects, and common patterns with simple examples and beginner-friendly explanations.
How to Copy a List in Python Without Changing the Original
Learn why assigning one Python list to another shares the same object, and how to copy lists safely using slice, list(), and copy().
How to Create a Directory and Missing Parent Directories in Python
Learn how to create nested directories in Python, including missing parent folders, similar to Bash mkdir -p.
How to Create a Time Delay in Python
Learn how to add a time delay in Python using time.sleep(), with examples, common mistakes, and practical use cases.
How to Delete a File or Folder in Python
Learn how to delete files and folders in Python using os and shutil, with examples, safety tips, and common mistakes beginners make.
How to Escape Curly Braces in Python .format Strings
Learn how to escape curly braces in Python .format strings, why double braces work, and how to print literal { and } safely.
Page 1 of 4 - 62 questions