In this quiz, you’ll test your understanding of How to Use Python: Taking Your First Steps. By working through this quiz, you’ll revisit Python’s readable syntax, keywords and variables, built-in data types, indentation and code blocks, functions, the difference between syntax errors and exceptions, coding tools, and PEP 8. These are the building blocks that everything else in Python rests on, so take your time with each question. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see…
Python 3.15 is (almost*) here! Christopher Trudeau and Bartosz Zaczyński return to discuss the new version. Bartosz coordinated the series of preview articles with members of the Real Python team and wrote the showcase tutorial, "Python 3.15: Cool New Features for You to Try." Christopher's video course "What's New in Python 3.15" covers the topics from the article and shows the new features in action. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]
Reviewed by: Sumit Sarabhai If you’ve been writing SQL in Python, you already know the debate: positional parameters (?) or named parameters (%(name)s)? Some developers swear by the conciseness of positional. Others prefer the clarity of named. With mssql-python, you no longer need to choose – we support both. We’ve added dual parameter style support to mssql-python, enabling both qmark and pyformat parameter styles in Python […] The post Write SQL Your Way: Dual Parameter Style Benefits in mssql-python appeared first on Microsoft for Python Developers Blog.
azurepythonexcerpt only · body stays at the source
In this quiz, you’ll test your understanding of Python’s collections: A Buffet of Specialized Data Types. Python’s collections module provides specialized container data types that approach specific programming problems more clearly and more efficiently than the general purpose built-ins do. You’ll revisit namedtuple() for readable code, deque for queues and stacks, defaultdict for missing keys, OrderedDict for ordering, Counter for tallies, ChainMap for multiple mappings, and the wrapper classes for customizing built-ins. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet…
In this quiz, you’ll test your understanding of Python 3.15 Preview: Sentinel Values. By working through this quiz, you’ll revisit what sentinel values are, where the classic object() idiom falls short, and how Python 3.15’s built-in sentinel type gives you readable signatures, precise type hints, and identity that survives copying and pickling. You’ll also practice deciding when a sentinel beats None, so you’ll know exactly which object() markers in your own code are worth replacing once you upgrade. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered…
In this quiz, you’ll test your understanding of What’s New in Python 3.15. By working through this quiz, you’ll revisit lazy imports, unpacking in comprehensions, frozendict, the new sentinel() built-in, friendlier error messages, the new sampling profiler, and UTF-8 as the default encoding. These are the features you’re most likely to reach for once you upgrade, so getting to know them now gives you a head start. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]
In this quiz, you’ll test your understanding of Python 3.15 Preview: frozendict. By working through this quiz, you’ll revisit how to build a frozen mapping, why it isn’t a dict subclass, what it takes to make one hashable, and exactly where the freeze stops. Python 3.15 finally gives dictionaries the immutable counterpart that lists and sets have had for years. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]
In this quiz, you’ll test your understanding of Python 3.15: Cool New Features for You to Try. By working through this quiz, you’ll revisit lazy imports, unpacking in comprehensions, the new frozendict and sentinel built-ins, sharper type hints, the Tachyon sampling profiler, UTF-8 by default, the upgraded JIT compiler, and what to check before you upgrade. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]
Python data types are fundamental to the language, enabling you to represent various kinds of data. You use basic data types like int, float, and complex for numbers, str for text, bytes and bytearray for binary data, and bool for Boolean values. These data types form the core of most Python programs, allowing you to handle numeric, textual, and logical data efficiently. Understanding Python data types involves recognizing their roles and how to work with them. You can create and manipulate these data types using built-in functions and methods, and convert between them when necessary. By the…
In this quiz, you’ll test your understanding of Operator and Function Overloading in Custom Python Classes. By working through this quiz, you’ll revisit how Python’s data model connects built-in functions and operators to the special methods on a class. You’ll cover both the forward and reverse forms of those operators. Overloading is what makes your own objects behave the way other Python programmers expect, so getting comfortable with these special methods pays off in every class you write. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your…
In this quiz, you’ll test your understanding of When Do You Use an Ellipsis in Python? By working through this quiz, you’ll revisit how ... relates to the Ellipsis object, how to use three dots as a placeholder when you write stubs, what they mean in tuple and Callable type hints, and how they shorten your NumPy slicing syntax. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]
In this quiz, you’ll test your understanding of Python Web Applications: Deploy Your Script as a Flask App. By working through this quiz, you’ll revisit what separates a web application from a static site, how Flask connects URLs to your Python functions, how to read and escape what your users type, and what it takes to get your code running on Google App Engine. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]
Python’s for loop allows you to iterate over the items in a collection, such as lists, tuples, strings, and dictionaries. The for loop syntax declares a loop variable that takes each item from the collection in each iteration. This loop is ideal for repeatedly executing a block of code on each item in the collection. You can also tweak for loops further with features like break, continue, and else. By the end of this tutorial, you’ll understand that: Python’s for loop iterates over items in a data collection, allowing you to execute code for each item. To iterate from 0 to 10, you use the for…
In this quiz, you’ll test your understanding of Using pandas and Python to Explore Your Dataset. By working through this quiz, you’ll revisit how to load a CSV file into a DataFrame, select and query your data with .loc and .iloc, group and aggregate values, handle missing data, and plot your results. The pandas library is one of the most popular tools for working with data in Python, so a solid foundation here will pay off. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see…
If you’re new to programming and considering Python, knowing what you can do with it can be motivating. Python is used in many fields, including web and desktop development, data science, artificial intelligence (AI), automation, robotics, and more. In this tutorial, you’ll explore tools, libraries, and project ideas that showcase Python’s versatility across these areas. By the end, you’ll know where to go next with your Python skills. By the end of this tutorial, you’ll understand that: You can build web applications with frameworks like Django, Flask, and FastAPI, each suitable for…
In this quiz, you’ll test your understanding of Exploring the MVC Pattern in Python. By working through this quiz, you’ll revisit what models, views, and controllers are, how a user’s request travels through each of them, and how routes and templates tie the pattern together in a Flask app. Once the pattern clicks, you’ll have a mental map that carries over to Django and most other web frameworks you’ll meet. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]
If you tell Python it’ll run x.__add__(5), which handles the int 5. But what about int.__add__ doesn’t know how to handle x. So it returns NotImplemented — and Python turns […] The post Python’s __radd__: How reflected operators handle 5 + x appeared first on LernerPython.
In this quiz, you’ll test your understanding of How to Get a List of All Files in a Directory With Python. By working through this quiz, you’ll revisit how .iterdir() hands you the contents of a single directory, how glob patterns let .glob() and .rglob() filter results by name, and how .rglob() walks an entire directory tree. You’ll also check your understanding of filtering on attributes with comprehensions and filter(), and of skipping junk directories instead of listing every file inside them. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to…
How does the “in” operator work in Python? – If an object defines __contains__, then its (boolean) result is returned (coerced to bool).– If not, then Python iterates over it […] The post Python in operator: How __contains__ speeds up membership tests appeared first on LernerPython.
In this quiz, you’ll revisit the core concepts covered in the LLM Application Development With Python learning path. You’ll check your understanding of connecting to LLM APIs, crafting effective prompts, working with LangChain, adding retrieval-augmented generation (RAG) with embeddings and vector databases, building AI agents with Pydantic AI and LangGraph, and connecting LLMs to external tools with the Model Context Protocol (MCP). [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and…
There are many ways to learn Python online, but there are also many people out there that want to learn Python for multiple reasons - so hey, why not add one more free Python course into the mix? I'm happy to finally release ProficientPython.com, my own approach to teaching introductory Python. The course covers standard intro topics - variables, functions, logic, loops, lists, strings, dictionaries, files, OOP. However, the course differs in two key ways from most others: It is based on functions from the very beginning (instead of being based on side effects). The coding exercises can be…
There are many ways to learn Python online, but there are also many people out there that want to learn Python for multiple reasons - so hey, why not add one more free Python course into the mix? I'm happy to finally release ProficientPython.com, my own approach to teaching introductory Python. The course covers standard intro topics - variables, functions, logic, loops, lists, strings, dictionaries, files, OOP. However, the course differs in two key ways from most others: It is based on functions from the very beginning (instead of being based on side effects). The coding exercises can be…
Reviewed by: Sumit Sarabhai and Gaurav Sharma If you’ve worked with databases in Python, you know the boilerplate: open a connection, create a cursor, run queries, commit or rollback transactions, close cursors and connection. Forgetting just one cleanup step can lead to resource leaks (open connections) or even inconsistent data. That’s where context managers step […] The post Simplifying Resource Management in mssql-python through Context Manager appeared first on Microsoft for Python Developers Blog.
azurepythonexcerpt only · body stays at the source
I wanted to implement concise “pattern matching” in Python, a language which unlike C#, F#, Scala, and so on, does not have any pattern matching built in. Logically a pattern is just a predicate: a function which takes a value … Continue reading →
uncategorizedexcerpt only · body stays at the source
To learn how to install Python on your system, you can follow a few straightforward steps. First, check if Python is already installed by opening a command-line interface and typing python --version or python3 --version. You can install Python on Windows using the official installer from Python.org or through the Microsoft Store. On macOS, you can use the official installer or Homebrew. For Linux, use your package manager or build Python from source. By the end of this tutorial, you’ll understand how to: Check if Python is installed by running python --version or python3 --version in a…
In this quiz, you’ll test your understanding of Python Basics Exercises: Strings and String Methods. By working through this quiz, you’ll revisit how to slice strings, change their case, strip whitespace, check how a string starts, chain string methods together, and format values for printing. Working with text is one of the most common tasks in Python, so these skills will come up again and again. Take your time with each question, and read the explanations to reinforce what you’ve practiced. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your…
In this quiz, you’ll test your understanding of Generate Images in Python With OpenAI’s GPT Image API. By working through this quiz, you’ll revisit how to install the OpenAI Python library, store your API key, generate images from text prompts with the GPT Image models, tune their size and quality, decode Base64 responses into PNG files, and edit an image with a follow-up prompt. [ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]
excerpt only · body stays at the source
From the web
Your visit, your choice.
Optional Google Analytics helps us understand visits. Microsoft Clarity records masked interactions to improve the site. Optional tools stay off unless you choose them. Privacy details.