Python tutorials

Quiz: Python Annotations

Interactive Quiz ⋅ 9 QuestionsBy Bartosz Zaczyński Share In this quiz, you’ll test your understanding of lazy annotations introduced in Python 3.14. By working through this quiz, you’ll revisit how they improve performance, address forward reference issues, and support both static type checking and runtime processing. The quiz contains 9 questions and there is no time limit. You’ll get 1 point for each correct answer. At the end of the quiz, you’ll receive a total score. The maximum score is […]

Read more

Python 3.14 Preview: Lazy Annotations

Recent Python releases have introduced several small improvements to the type hinting system, but Python 3.14 brings a single major change: lazy annotations. This change delays annotation evaluation until explicitly requested, improving performance and resolving issues with forward references. Library maintainers might need to adapt, but for regular Python users, this change promises a simpler and faster development experience. Explore how lazy annotations in Python 3.14 streamline your development process, offering both performance benefits and enhanced code clarity. If you’re […]

Read more

Quiz: Python Skill Test

Interactive Quiz ⋅ 12 QuestionsBy Martin Breuss Share 🐍 How Strong Are Your Python Skills? 🚀 This quick quiz gives you a snapshot of where you stand, whether you’re just starting out with Python or have years of coding under your belt. Test your Python skill by answering questions ranging from fundamentals to more advanced challenges. Each question is designed to test your understanding and maybe even teach you something new. Tip: Read the Explanation for each answer and follow […]

Read more

Profiling Performance in Python

Do you want to optimize the performance of your Python program to make it run faster or consume less memory? Before diving into any performance tuning, you should strongly consider using a technique called software profiling. It can help you decide whether optimizing the code is necessary and, if so, which parts of the code you should focus on. Sometimes, the return on investment in performance optimizations just isn’t worth the effort. If you only run your code once or […]

Read more

Quiz: How to Write Docstrings in Python

Interactive Quiz ⋅ 7 QuestionsBy Philipp Acsany Share Want to get comfortable writing and using Python docstrings? This quiz helps you revisit best practices, standard conventions, and common tools. You’ll review the basics of docstring syntax, how to read them at runtime, and different formatting styles. For more details, check out the tutorial How to Write Docstrings in Python. The quiz contains 7 questions and there is no time limit. You’ll get 1 point for each correct answer. At the […]

Read more

How to Write Docstrings in Python

Writing clear, consistent docstrings in Python helps others understand your code’s purpose, parameters, and outputs. In this guide on how to write docstrings in Python, you’ll learn about best practices, standard formats, and common pitfalls to avoid, ensuring your documentation is accessible to users and tools alike. By the end of this tutorial, you’ll understand that: Docstrings are strings used to document your Python code and can be accessed at runtime. Python comments and docstrings have important differences. One-line and […]

Read more

Python’s with Statement: Manage External Resources Safely

Watch Now This tutorial has a related video course created by the Real Python team. Watch it together with the written tutorial to deepen your understanding: Context Managers and Using Python’s with Statement Python’s with statement allows you to manage external resources safely by using objects that support the context manager protocol. These objects automatically handle the setup and cleanup phases of common operations. By using the with statement alongside appropriate context managers, you can focus on your core logic […]

Read more

Working With Python’s .__dict__ Attribute

Python’s .__dict__ is a special attribute in classes and instances that acts as a namespace, mapping attribute names to their corresponding values. You can use .__dict__ to inspect, modify, add, or delete attributes dynamically, which makes it a versatile tool for metaprogramming and debugging. In this video course, you’ll learn about using .__dict__ in various contexts, including classes, instances, and functions. You’ll also explore its role in inheritance with practical examples and comparisons to other tools for manipulating attributes. By […]

Read more

Python 3.14 Release Candidate Lands: Faster Code, Smarter Concurrency

Last month, Python 3.14 reached its first release candidate, pushing the interpreter past beta and onto the home stretch toward its final release on October 7. But that headline was only the start—new library releases also landed, Django celebrated its 20th birthday, and EuroPython brought the community together in Prague. What follows is a quick-read digest of everything that mattered, from core-language breakthroughs to tooling upgrades and community milestones. Feel free to skip straight to whatever interests you most. Python […]

Read more

Quiz: Python Basics: Setting Up Python

Interactive Quiz ⋅ 5 QuestionsBy Martin Breuss Share In this quiz, you will review the key steps for installing Python on Windows, macOS, and Ubuntu Linux. You will recall what the PATH environment variable is for, and what Python distribution to choose. Note: The explanations in the questions will link back to the Windows installation lesson, but all question are kept general, so you’ll be able to answer them independent of which operating system you use. You’ll also revisit how […]

Read more
1 2 3 4 5 200