Python tutorials

500× faster: Four different ways to speed up your code

If your Python code is slow and needs to be fast, there are many different approaches you can take, from parallelism to writing a compiled extension. But if you just stick to one approach, it’s easy to miss potential speedups, and end up with code that is much slower than it could be. To make sure you’re not forgetting potential sources of speed, it’s useful to think in terms of practices. Each practice: Speeds up your code in its own […]

Read more

Quiz: Python 3.14 Preview: Template Strings (T-Strings)

Interactive Quiz ⋅ 11 QuestionsBy Leodanis Pozo Ramos Share Evaluate your grasp of Python’s t-strings, which provide a structured and secure way to handle string templates. The quiz contains 11 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 100%. Good luck! Related Resources

Read more

Python 3.14 Preview: Template Strings (T-Strings)

Python 3.14’s t-strings allow you to intercept and transform input values before assembling them into a final representation. Unlike f-strings, which produce a str object, t-strings resolve to a Template instance, allowing you to safely process and customize dynamic content. One of the key benefits of t-strings is their ability to help prevent security vulnerabilities like SQL injection and XSS attacks. They’re also valuable in other fields that rely on string templates, such as structured logging. By the end of […]

Read more

Implementing the Factory Method Pattern in Python

This video course explores the Factory Method design pattern and its implementation in Python. Design patterns became a popular topic in late 90s after the so-called Gang of Four (GoF: Gamma, Helm, Johson, and Vlissides) published their book Design Patterns: Elements of Reusable Object-Oriented Software. The book describes design patterns as a core design solution to reoccurring problems in software and classifies each design pattern into categories according to the nature of the problem. Each pattern is given a name, […]

Read more

Quiz: Use TorchAudio to Prepare Audio Data for Deep Learning

Interactive Quiz ⋅ 10 QuestionsBy Bartosz Zaczyński Share In this quiz, you’ll test your understanding of audio fundamentals and how to Use TorchAudio to Prepare Audio Data for Deep Learning. You’ll revisit fundamental terminology and how to: Install and import TorchAudio Load audio waveform datasets Apply signal transforms Work through these questions to check your knowledge about building audio workflows for machine learning in Python. The quiz contains 10 questions and there is no time limit. You’ll get 1 point […]

Read more

Use TorchAudio to Prepare Audio Data for Deep Learning

Ever wondered how machine learning models process audio data? How do you handle different audio lengths, convert sound frequencies into learnable patterns, and make sure your model is robust? This tutorial will show you how to handle audio data using TorchAudio, a PyTorch-based toolkit. You’ll work with real speech data to learn essential techniques like converting waveforms to spectrograms, standardizing audio lengths, and adding controlled noise to build machine and deep learning models. Dive into the tutorial to explore these […]

Read more

Quiz: The Python print() Function

Interactive Quiz ⋅ 12 QuestionsBy Bartosz Zaczyński Share In this quiz, you’ll test your understanding of Your Guide to the Python print() Function. The print() function outputs objects to the console or a specified file-like stream. You’ll practice: Printing multiple values with custom separators Changing the end-of-line character Redirecting output using the file parameter Forcing immediate output with the flush parameter Work through these questions to reinforce your knowledge of print()’s parameters and best practices for clear, formatted I/O. The […]

Read more

Your Guide to the Python print() Function

If you’re like most Python users, then you probably started your Python journey by learning about print(). It helped you write your very own “Hello, World!” one-liner and brought your code to life on the screen. Beyond that, you can use it to format messages and even find some bugs. But if you think that’s all there is to know about Python’s print() function, then you’re missing out on a lot! Keep reading to take full advantage of this seemingly […]

Read more

Starting With DuckDB and Python

The DuckDB database provides a seamless way to handle large datasets in Python with Online Analytical Processing (OLAP) optimization. You can create databases, verify data imports, and perform efficient data queries using both SQL and DuckDB’s Python API. By the end of this video course, you’ll understand that: You can create a DuckDB database by reading data from files like Parquet, CSV, or JSON and saving it to a table. You query a DuckDB database using standard SQL syntax within […]

Read more

Python enumerate(): Simplify Loops That Need Counters

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: Looping With Python enumerate() Python’s enumerate() function helps you with loops that require a counter by adding an index to each item in an iterable. This is particularly useful when you need both the index and value while iterating, such as listing items with their positions. You can also customize the starting index with […]

Read more
1 2 3 194