Python tutorials

Create Callable Instances With Python’s .__call__()

In Python, a callable is any object that you can call using a pair of parentheses and, optionally, a series of arguments. Functions, classes, and methods are all common examples of callables in Python. Besides these, you can also create custom classes that produce callable instances. To do this, you can add the .__call__() special method to your class. Instances of a class with a .__call__() method behave like functions, providing a flexible and handy way to add functionality to […]

Read more

Quiz: GeoPandas Basics: Maps, Projections, and Spatial Joins

Interactive Quiz ⋅ 9 QuestionsBy Joseph Peart Share In this quiz, you’ll test your understanding of GeoPandas. You’ll review coordinate reference systems, GeoDataFrames, interactive maps, and spatial joins with .sjoin(). You’ll also explore how projections affect maps and learn best practices for working with geospatial data. This quiz helps you confirm that you can prepare, visualize, and analyze geospatial data accurately using GeoPandas. The quiz contains 9 questions and there is no time limit. You’ll get 1 point for each […]

Read more

GeoPandas Basics: Maps, Projections, and Spatial Joins

GeoPandas extends pandas to make working with geospatial data in Python intuitive and powerful. If you’re looking to do geospatial tasks in Python and want a library with a pandas-like API, then GeoPandas is an excellent choice. This tutorial shows you how to accomplish four common geospatial tasks: reading in data, mapping it, applying a projection, and doing a spatial join. By the end of this tutorial, you’ll understand that: GeoPandas extends pandas with support for spatial data. This data […]

Read more

Quiz: How to Integrate Local LLMs With Ollama and Python

Interactive Quiz ⋅ 8 QuestionsBy Bartosz Zaczyński Share In this quiz, you’ll test your understanding of How to Integrate Local LLMs With Ollama and Python. By working through this quiz, you’ll revisit how to set up Ollama, pull models, and use chat, text generation, and tool calling from Python. You’ll connect to local models through the ollama Python library and practice sending prompts and handling responses. You’ll also see how local inference can improve privacy and cost efficiency while keeping […]

Read more

How to Integrate Local LLMs With Ollama and Python

Integrating local large language models (LLMs) into your Python projects using Ollama is a great strategy for improving privacy, reducing costs, and building offline-capable AI-powered apps. Ollama is an open-source platform that makes it straightforward to run modern LLMs locally on your machine. Once you’ve set up Ollama and pulled the models you want to use, you can connect to them from Python using the ollama library. Here’s a quick demo: In this tutorial, you’ll integrate local LLMs into your […]

Read more

uv vs pip: Python Packaging and Dependency Management

When it comes to Python package managers, the choice often comes down to uv vs pip. You may choose pip for out-of-the-box availability, broad compatibility, and reliable ecosystem support. In contrast, uv is worth considering if you prioritize fast installs, reproducible environments, and clean uninstall behavior, or if you want to streamline workflows for new projects. In this video course, you’ll compare both tools. To keep this comparison meaningful, you’ll focus on the overlapping features, primarily package installation and dependency […]

Read more

Quiz: How to Integrate ChatGPT’s API With Python Projects

Interactive Quiz ⋅ 8 QuestionsBy Bartosz Zaczyński Share In this quiz, you’ll test your understanding of How to Integrate ChatGPT’s API With Python Projects. By working through this quiz, you’ll revisit how to send prompts with the openai library, guide behavior with developer role messages, and handle text and code outputs. You’ll also see how to integrate AI responses into your Python scripts for practical tasks. The quiz contains 8 questions and there is no time limit. You’ll get 1 […]

Read more

How to Integrate ChatGPT’s API With Python Projects

Python’s openai library provides the tools you need to integrate the ChatGPT API into your Python applications. With it, you can send text prompts to the API and receive AI-generated responses. You can also guide the AI’s behavior with developer role messages and handle both simple text generation and more complex code creation tasks. Here’s an example: Python Script Output from a ChatGPT API Call Using openai After reading this tutorial, you’ll understand how examples like this work under the […]

Read more

Quiz: How to Create a Django Project

Interactive Quiz ⋅ 5 QuestionsBy Martin Breuss Share In this quiz, you’ll test your understanding of creating a Django project. By working through this quiz, you’ll revisit how to create and activate a virtual environment, install Django and pin your dependencies, start a Django project, and start a Django app. You will also see how isolating dependencies helps others reproduce your setup. To revisit and keep learning, watch the video course on How to Set Up a Django Project. The […]

Read more

How to Create a Django Project

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: How to Set Up a Django Project Before you can start building your Django web application, you need to set up your Django project. In this guide you’ll learn how to create a new Django project in four straightforward steps and only six commands: Step Description Command 1a Set up a virtual environment python […]

Read more
1 2 3 208