Python tutorials

Draw the Mandelbrot Set in Python

This tutorial will guide you through a fun project involving complex numbers in Python. You’re going to learn about fractals and create some truly stunning art by drawing the Mandelbrot set using Python’s Matplotlib and Pillow libraries. Along the way, you’ll learn how this famous fractal was discovered, what it represents, and how it relates to other fractals. Knowing about object-oriented programming principles and recursion will enable you to take full advantage of Python’s expressive syntax to write clean code […]

Read more

Raining Outside? Build a Weather CLI App With Python

You’re stuck inside because of torrential rains—again! You wonder what the weather’s like in that faraway city where your friends from the Real Python community live. You’d rather stick around in your command-line interface (CLI) than look it up in your browser. If that sounds like a task you’d want to tackle by building a command-line weather app using only the Python standard library, then this tutorial is for you. In this tutorial, you’ll learn how to: Build a functional […]

Read more

The fastest way to read a CSV in Pandas

You have a large CSV, you’re going to be reading it in to Pandas—but every time you load it, you have to wait for the CSV to load. And that slows down your development feedback loop, and might meaningfully slows down your production processing. But it’s faster to read the data in faster. Let’s see how. In this article we’ll cover: Pandas’ default CSV reading. The faster, more parallel CSV reader introduced in v1.4. A different approach that can make […]

Read more

Looping With Python enumerate()

In Python, a for loop is usually written as a loop over an iterable object. This means that you don’t need a counting variable to access items in the iterable. Sometimes, though, you do want to have a variable that changes on each loop iteration. Rather than creating and incrementing a variable yourself, you can use Python’s enumerate() to get a counter and the value from the iterable at the same time! In this course, you’ll see how to: Use […]

Read more

Modulo String Formatting in Python

If you’re writing modern Python code with Python 3, you’ll probably want to format your strings with Python f-strings. However, if you’re working with older Python codebases, you’re likely to encounter the string modulo operator for string formatting. If you’re reading or writing Python 2 code, it’ll help if you’re familiar with this technique. Because the syntax still works in Python 3, you might even see developers use it in modern Python codebases. In this tutorial, you’ll learn how to: […]

Read more

How vectorization speeds up your Python code

Python is not the fastest programming language. So when you need to process a large amount of homogeneous data quickly, you’re told to rely on “vectorization.” This leads to more questions: What does “vectorization” actually mean? When does it apply? How does vectorization actually make code faster? To answer that question, we’ll consider interesting performance metrics, learn some useful facts about how CPUs work, and discover that NumPy developers are working hard to make your code faster. What “vectorization” means, […]

Read more

Build a Dice-Rolling Application With Python

Building small projects, like a text-based user interface (TUI) dice-rolling application, will help you level up your Python programming skills. You’ll learn how to gather and validate the user’s input, import code from modules and packages, write functions, use for loops and conditionals, and neatly display output by using strings and the print() function. In this project, you’ll code an application that simulates dice-rolling events. To do so, you’ll use Python’s random module. In this tutorial, you’ll learn how to: […]

Read more

Starting With Python IDLE

If you’ve recently downloaded Python onto your computer, then you may have noticed a new program on your machine called IDLE. You might be wondering, “What is this program doing on my computer? I didn’t download that!” While you may not have downloaded this program on your own, IDLE comes bundled with every Python installation. It’s there to help you get started with the language right out of the box. In this course, you’ll learn how to work in Python […]

Read more

Python News: What’s New From December 2021?

In December 2021, the fourth Python steering council was elected, as usual with a mix of new and returning members. Python’s release-cycle circle of life kept spinning, with new iterations of both Python 3.10 and the upcoming Python 3.11 released. At the same time, the popular Python 3.6 reached end-of-life and will no longer be supported. Amid this flurry of activity, developers from all over had some fun over the holidays by solving the annual Advent of Code puzzles. Let’s […]

Read more
1 97 98 99 100 101 181