Questions

Python questions

Choose a question page, learn the concept, then test your understanding with a quiz.

How to Sort a List of Dictionaries by Key in Python

Learn how to sort a list of dictionaries by a key in Python using sorted() and list.sort() with clear examples and common mistakes.

pythonlistsortingdictionary

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

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

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 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 Function Decorators: How to Create and Chain Them Together

Learn how to write Python function decorators and stack them correctly to wrap return values like bold and italic HTML tags.

pythonfunctiondecoratorpython-decorators

Python List append() vs extend(): What’s the Difference?

Learn the difference between Python list append() and extend() with clear examples, behavior comparisons, and common mistakes.

pythonlistdata-structuresappend

Python Mutable Default Arguments Explained: Why Defaults Are Evaluated Once

Learn why Python mutable default arguments are evaluated at function definition time, how bugs happen, and the safe pattern to use instead.

pythonlanguage-designdefault-parametersleast-astonishment

Python Static Variables and Methods: Class Variables, @classmethod, and @staticmethod

Learn how class variables and static methods work in Python, when to use them, and how they differ from instance variables and methods.

pythonclassstaticclass-variables

Python String Contains: How to Check for a Substring in Python

Learn how to check whether a Python string contains a substring using `in`, `find()`, and related techniques with examples.

pythonstringsubstringcontains

Python String Slicing: How to Get a Substring in Python

Learn how to get substrings in Python using string slicing, including start, end, omitted indexes, and practical examples.

pythonstringsubstring

Select Rows by Column Values in Pandas DataFrames

Learn how to filter rows in a Pandas DataFrame by column values using boolean indexing, multiple conditions, and common patterns.

pythonpandasdataframeindexing

Understanding Python super() with __init__() Methods

Learn why Python super() is used, how it differs from Base.__init__(), and when to use each in inheritance.

pythonclassoopinheritance

What Are Metaclasses in Python? A Beginner-Friendly Guide

Learn what metaclasses are in Python, how they work, why they matter, and when to use them with simple examples.

pythonoopmetaclasspython-class

What __init__.py Is For in Python Packages

Learn what __init__.py does in Python, why it exists in packages, and how it is used for imports, setup, and module organization.

pythonmodulepackagepython-packaging

What `if __name__ == "__main__":` Does in Python

Learn what `if __name__ == "__main__":` means in Python, why it matters, and how it controls code when files are run or imported.

pythonnamespacesprogram-entry-pointpython-module

What the yield Keyword Does in Python

Learn what Python's yield keyword does, how generators work, and what happens when generator functions are called and iterated.

pythoniteratorgeneratoryield

Page 3 of 4 - 62 questions