Questions
Python questions
Choose a question page, learn the concept, then test your understanding with a quiz.
How to Split a List Into Equal-Sized Chunks in Python
Learn how to split a Python list into equal-sized chunks with clear examples, step-by-step logic, common mistakes, and a mini project.
How to Upgrade All Python Packages with pip
Learn how to upgrade all installed Python packages with pip, why pip has no single built-in command, and safe ways to do it step by step.
How to Use Global Variables in Python Functions
Learn how global variables work in Python functions, when to use the global keyword, and how to avoid UnboundLocalError.
How to Write JSON Data to a File in Python
Learn how to write a Python dictionary to a JSON file correctly using json.dump and json.dumps with simple examples.
Inspecting Object Properties and Values in JavaScript
Learn how to inspect JavaScript objects with console.log, console.dir, Object.keys, and JSON.stringify for effective debugging.
Install pip on macOS: Python Package Manager Guide
Learn how to check, install, and use pip on macOS with Python 3, including ensurepip, Homebrew, virtual environments, and fixes for common errors.
Iterating Over Dictionary Keys with a for Loop in Python
Learn how Python for loops iterate over dictionary keys, why `key` is just a variable name, and how dict iteration works in practice.
Make a Python Class JSON Serializable
Learn why Python objects are not JSON serializable by default and how to convert classes to JSON safely using dictionaries, default functions, and encoders.
Move Files in Python with shutil.move()
Learn how to move and rename files in Python with shutil.move(), including paths, overwrite behavior, errors, and practical examples.
Multiline Comments in Python: Docstrings and Commenting Blocks
Learn how to write multiline comments in Python using line comments and docstrings, including best practices, examples, and common mistakes.
Place a Matplotlib Legend Outside the Plot Area
Learn how to place a Matplotlib legend outside an axes, reduce legend font size, and save figures without shrinking the plot area.
Print Full Python Exception Tracebacks Without Exiting
Learn how to catch Python exceptions, print their complete tracebacks with traceback.print_exc(), log them, and keep your program running.
Print Python Exceptions and Tracebacks in except Blocks
Learn how to print Python exception messages and full tracebacks with except, as, traceback, and safe exception handling patterns.
Python *args and **kwargs Explained in Function Parameters
Learn what *args and **kwargs mean in Python function parameters, how they work, when to use them, and common mistakes to avoid.
Python *args and **kwargs: Variable Function Arguments
Learn how Python *args and **kwargs collect flexible function arguments, unpack lists and dictionaries, and support reusable APIs.
Python 3 http.server: Equivalent of SimpleHTTPServer
Learn the Python 3 replacement for python -m SimpleHTTPServer, how to serve files locally, choose ports, and stop the server safely.
Python @classmethod vs @staticmethod Explained for Beginners
Learn what @classmethod and @staticmethod mean in Python, how they differ from instance methods, and when to use each one clearly.
Python Argument Passing Explained: Pass by Reference vs Rebinding
Learn how Python argument passing works, why rebinding a parameter does not change the caller, and how to mutate objects correctly.
Python Current Working Directory vs Script Directory Explained
Learn how to get the current working directory and the running Python file's directory, with examples, differences, and common mistakes.
Python Dictionary Comprehensions: Create Dictionaries from Key-Value Pairs
Learn how to create Python dictionaries with dictionary comprehensions, zip(), conditions, duplicate-key behavior, and practical examples.