Python tutorials

Python’s tuple Data Type: A Deep Dive With Examples

In Python, a tuple is a built-in data type that allows you to create immutable sequences of values. The values or items in a tuple can be of any type. This makes tuples pretty useful in those situations where you need to store heterogeneous data, like that in a database record, for example. Through this tutorial, you’ll dive deep into Python tuples and get a solid understanding of their key features and use cases. This knowledge will allow you to […]

Read more

What’s New in Python 3.12

It’s that time of year again, time for a new release of Python. Although Python 3.12 mostly focuses on internal improvements, there’s a little something for everyone. You can read up on all the new features by checking out the changelog. In this video course, you’ll learn about the following changes: Improvements to f-strings More did-you-mean error messages New features in the standard library Additions to static typing Changes to the CPython interpreter In this video course, you’ll explore these […]

Read more

Python 3.12: Cool New Features for You to Try

Python 3.12 was published on October 2, 2023. As usual, the new version comes out in October after lots of effort by volunteers worldwide. The new version comes with several new features and improvements that you’ll explore in this tutorial. You can also dive into the documentation to see a complete list of all changes. In this tutorial, you’ll learn about new features and improvements, like: Better error messages with helpful suggestions and guidance More expressive f-strings that are backed […]

Read more

Python 3.12 Preview: Static Typing Improvements

Python’s support for static typing gradually improves with each new release of Python. The core features were in place in Python 3.5. Since then, there’ve been many tweaks and improvements to the type hinting system. This evolution continues in Python 3.12, which, in particular, simplifies the typing of generics. In this tutorial, you’ll: Use type variables in Python to annotate generic classes and functions Explore the new syntax for type hinting type variables Model inheritance with the new @override decorator […]

Read more

Python Basics Exercises: Conditional Logic and Control Flow

In Python Basics: Conditional Logic and Control Flow, you learned that much of the Python code you’ll write is unconditional. That is, the code doesn’t make any choices. Every line of code is executed in the order that it’s written or in the order that functions are called, with possible repetitions inside loops. In this course, you’ll revisit how to use conditional logic to write programs that perform different actions based on different conditions. Paired with functions and loops, conditional […]

Read more

Python 3.12 Preview: Subinterpreters

Now that you know what a Python subinterpreter is, you’ll take a look at what’s changing in the upcoming releases of CPython. Most of the subinterpreter changes are described in two proposals, PEP 684 and PEP 554. Only PEP 684 will make it into the 3.12 release. PEP 554 is scheduled for the 3.13 release but hasn’t been officially approved yet. Changes to the Global State and the GIL The main focus of PEP 684 is refactoring the internals of […]

Read more

Speeding up your code when multiple cores aren’t an option

The common advice when Python is too slow is to switch to a low-level compiled language like Cython or Rust. But what do you do if that code is too slow? At that point you might start thinking about parallelism: using multi-threading or multi-processing so you can take advantage of multiple CPU cores. But parallelism comes with its own set of complexities; at the very least, some algorithms can only really work in a single-threaded way. So what can you […]

Read more

How to Catch Multiple Exceptions in Python

In this tutorial, you’ll learn various techniques to catch multiple exceptions with Python. To begin with, you’ll review Python’s exception handling mechanism before diving deeper and learning how to identify what you’ve caught, sometimes ignore what you’ve caught, and even catch lots of exceptions. Python raises an exception when your code encounters an occasional but not unexpected error. For example, this will occur if you try to read a missing file. Because you’re aware that such exceptions may occur, you […]

Read more

Design and Guidance: Object-Oriented Programming in Python

Writing good object-oriented code is about more than just how to write the syntax. Knowing when and when not to use it, as well as guiding principles behind object-oriented design will help you write better code. In this course, you’ll learn about: The objected-oriented approach in Python vs other languages Cases in which you shouldn’t use classes in Python Alternatives to inheritance in structuring your code The SOLID principles for improving your code SOLID is an acronym for five principles […]

Read more

Operators and Expressions in Python

In Python, operators are special symbols, combinations of symbols, or keywords that designate some type of computation. You can combine objects and operators to build expressions that perform the actual computation. So, operators are the building blocks of expressions, which you can use to manipulate your data. Therefore, understanding how operators work in Python is essential for you as a programmer. In this tutorial, you’ll learn about the operators that Python currently supports. You’ll also learn the basics of how […]

Read more
1 35 36 37 38 39 189