Python tutorials

Python String Formatting: Available Tools and Their Features

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: Python String Formatting Tips & Best Practices String formatting is the process of applying a proper format to a given value while using this value to create a new string through interpolation. Python has several tools for string interpolation that support many formatting features. In modern Python, you’ll use f-strings or the .format() method […]

Read more

Python Interfaces: Object-Oriented Design Principles

Interfaces play an important role in software engineering. As an application grows, updates and changes to the code base become more difficult to manage. More often than not, you wind up having classes that look very similar but are unrelated, which can lead to some confusion. In this video course, you’ll see how you can use a Python interface to help determine what class you should use to tackle the current problem. In this video course, you’ll be able to: […]

Read more

Quiz: String Interpolation in Python: Exploring Available Tools

Interactive Quiz ⋅ 13 QuestionsBy Leodanis Pozo Ramos Share Or copy the link: Copied! Happy Pythoning! Test your understanding of Python’s tools for string interpolation, including f-strings, the .format() method, and the modulo operator. Take this quiz after reading our String Interpolation in Python: Exploring Available Tools tutorial. The quiz contains 13 questions and there is no time limit. You’ll get 1 point for each correct answer. At the end    

Read more

String Interpolation in Python: Exploring Available Tools

String interpolation allows you to create strings by inserting objects into specific places in a target string template. Python has several tools for string interpolation, including f-strings, the str.format() method, and the modulo operator (%). Python’s string module also provides the Template class, which you can use for string interpolation. In this tutorial, you’ll: Learn how to use f-strings for eager string interpolation Perform lazy string interpolation using the str.format() method Learn the basics of using the modulo operator (%) […]

Read more

Let’s optimize! Running 15× faster with a situation-specific algorithm

Let’s speed up some software! Our motivation: we have an image, a photo of some text from a book. We want to turn it into a 1-bit image, with just black and white, extracting the text so we can easily read it. We’ll use an example image from scikit-image, an excellent image processing library: from skimage.data import page import numpy as np IMAGE = page() assert IMAGE.dtype == np.uint8 Here’s what it looks like (it’s licensed under this license): The […]

Read more

What Are CRUD Operations?

The idea of CRUD is strongly connected with databases. That’s why it’s no surprise that CRUD operations correspond almost one-to-one with SQL commands: When you create data, you’re using the INSERT command to add new records to a table. After creation, you may read data using SELECT. With a SELECT query, you’re asking the database to retrieve the specific pieces of information you need, whether it’s a single value, a set of records, or complex relationships between data points. The […]

Read more

Efficient Iterations With Python Iterators and Iterables

Python’s iterators and iterables are two different but related tools that come in handy when you need to iterate over a data stream or container. Iterators power and control the iteration process, while iterables typically hold data that you want to iterate over one value at a time. Iterators and iterables are fundamental components of Python programming, and you’ll have to deal with them in almost all your programs. Learning how they work and how to create them is key […]

Read more

How to Create Pivot Tables With pandas

A pivot table is a data analysis tool that allows you to take columns of raw data from a pandas DataFrame, summarize them, and then analyze the summary data to reveal its insights. Pivot tables allow you to perform common aggregate statistical calculations such as sums, counts, averages, and so on. Often, the information a pivot table produces reveals trends and other observations your original raw data hides. Pivot tables were originally implemented in early spreadsheet packages and are still […]

Read more

Quiz: How to Create Pivot Tables With pandas

Interactive Quiz ⋅ 10 QuestionsBy Ian Eyre Share Or copy the link: Copied! Happy Pythoning! In this quiz, you’ll test your understanding of how to create pivot tables with pandas. By working through this quiz, you’ll review your knowledge of pivot tables and also expand beyond what you learned in the tutorial. For some of the questions, you’ll need to do some research outside of the tutorial itself. The quiz    

Read more

The Python calendar Module: Create Calendars With Python

The Python calendar module provides several ways to generate calendars for Python programs. It also includes a variety of functions for working with calendar data as strings, numbers, and datetime objects. In this tutorial, you’ll learn how to use the calendar module to create and customize calendars with Python. By the end of this tutorial, you’ll be able to: Display calendars in your terminal with Python Create plain text and HTML calendars Format calendars for specific locales and display conventions […]

Read more
1 14 15 16 17 18 183