Python tutorials

Quiz: Python Mappings

Interactive Quiz ⋅ 6 QuestionsBy Bartosz Zaczyński Share Or copy the link: Copied! Happy Pythoning! In this quiz, you’ll test your understanding of the basic characteristics and operations of Python mappings. By working through this quiz, you’ll revisit the key concepts and techniques of creating a custom mapping. The quiz contains 6 questions and there is no time limit. You’ll get 1 point for each correct answer. At the end    

Read more

Python Mappings: A Comprehensive Guide

One of the main data structures you learn about early in your Python learning journey is the dictionary. Dictionaries are the most common and well-known of Python’s mappings. However, there are other mappings in Python’s standard library and third-party modules. Mappings share common characteristics, and understanding these shared traits will help you use them more effectively. Take the Quiz: Test your knowledge with our interactive “Python Mappings” quiz. You’ll receive a score upon completion to help you track your learning […]

Read more

Listing All Files in a Directory With Python

Getting a list of all the files and folders in a directory is a natural first step for many file-related operations in Python. When looking into it, though, you may be surprised to find various ways to go about it. When you’re faced with many ways of doing something, it can be a good indication that there’s no one-size-fits-all solution to your problems. Most likely, every solution will have its own advantages and trade-offs. This is the case when it […]

Read more

Python News: What’s New From May 2024

May was packed with exciting updates and events in the Python community. This month saw the release of the first beta version of Python 3.13, the conclusion of PyCon US 2024, and the announcement of the keynote speakers for EuroPython 2024. Additionally, PEP 649 has been delayed until the Python 3.14 release, and the Python Software Foundation published its 2023 Annual Impact Report. Get ready to explore the recent highlights! The First Beta Version of Python 3.13 Released After nearly […]

Read more

Quiz: Python String Formatting: Available Tools and Their Features

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

Read more

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
1 21 22 23 24 25 191