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.

pythonlistsplitchunks

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.

pythonpippypi

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.

pythonglobal-variablesscope

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.

pythonjson

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.

pythondebuggingintrospectionpretty-print

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.

pythonmacospipinstallation

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.

pythonloopsdictionarykey

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.

pythonjsonserialization

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.

pythonfilefile-handlingpython-os

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.

pythoncommentsdocumentation

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.

pythonmatplotlibseabornlegend

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.

pythonexceptiontry-catchtraceback

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.

pythonexceptionerror-handling

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.

pythonsyntaxparameter-passingvariadic-functions

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.

pythonargskeyword-argument

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.

pythonpython-3.xhttpserversimplehttpserver

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.

pythonoopstatic-methodsclass-method

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.

pythonreferenceparameter-passingpass-by-reference

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.

pythondirectory

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.

pythondictionarylist-comprehensiondictionary-comprehension

Page 6 of 9 - 162 questions