Python tutorials

Build a Quiz Application With Python

In this tutorial, you’ll build a Python quiz application for the terminal. The word quiz was first used in 1781 to mean eccentric person. Nowadays, it’s mostly used to describe short tests of trivia or expert knowledge with questions like the following: When was the first known use of the word quiz? By following along in this step-by-step project, you’ll build an application that can test a person’s expertise on a range of topics. You can use this project to […]

Read more

LBYL vs EAFP: Preventing or Handling Errors in Python

Dealing with errors and exceptional situations is a common requirement in programming. You can either prevent errors before they happen or handle errors after they’ve happened. In general, you’ll have two coding styles matching these strategies: look before you leap (LBYL), and easier to ask forgiveness than permission (EAFP), respectively. In this tutorial, you’ll dive into the questions and considerations surrounding LBYL vs EAFP in Python. By learning about Python’s LBYL and EAFP coding styles, you’ll be able to decide […]

Read more

Data Cleaning With pandas and NumPy

Data scientists spend a large amount of their time cleaning datasets so that they’re easier to work with. In fact, the 80/20 rule says that the initial steps of obtaining and cleaning data account for 80% of the time spent on any given project. So, if you’re just stepping into this field or planning to step into this field, it’s important to be able to deal with messy data, whether that means missing values, inconsistent formatting, malformed records, or nonsensical […]

Read more

Python News: What’s New From May 2022

The first days of May 2022 were the last days of this year’s PyCon US event. Just before the PyCon conference, the Python Language Summit brought together Python core developers, triagers, and special guests. Some of those attendees were the very same people who shipped two important Python releases this month. The third Thursday of May marked Global Accessibility Awareness Day. This day aims to raise awareness of how to build inclusive digital products. Read on to dive into the […]

Read more

Making pip installs a little less slow

Installing your Python application’s dependencies can be surprisingly slow. Whether you’re running tests in CI, building a Docker image, or installing an application, downloading and installing dependencies can take a while. So how do you speed up installation with pip? In this article I’ll cover: Avoiding the slow path of installing from source. pip download speed, and the alternatives: Pipenv and Poetry. A useful pip option that can, sometimes, speed up installation significantly. Avoiding installs from source When you install […]

Read more

Level Up Your Skills With the Real Python Slack Community

The Real Python Community Slack is an English-medium Python community with members located worldwide. It’s a welcoming group in which you’re free to discuss any questions you may have, celebrate your progress, or hang out with the community at the virtual watercooler. This guide is for you if you want to: Get the most out of the Real Python Slack community Navigate some of Slack’s most valuable features Get your questions answered by other Real Python members Learn the dos […]

Read more

Exploring Scopes and Closures in Python

Have you been wondering how scopes and closures work in Python? Maybe you’ve just heard about object.__closure__, and you’d like to figure out what exactly it does. In this Code Conversation video course, you’ll use the debugger Thonny to walk through some sample code and get a better understanding of scopes and closures in Python. In this Code Conversation video course, you’ll: Clarify code by refactoring it with descriptive names Learn how functions access variables in local and nonlocal scopes […]

Read more

How to Publish an Open-Source Python Package to PyPI

Python is famous for coming with batteries included, and many sophisticated capabilities are available in the standard library. However, to unlock the full potential of the language, you should also take advantage of the community contributions at PyPI: the Python Packaging Index. PyPI, typically pronounced pie-pee-eye, is a repository containing several hundred thousand packages. These range from trivial Hello, World implementations to advanced deep learning libraries. In this tutorial, you’ll learn how to upload your own package to PyPI. Publishing […]

Read more

CPUs, cloud VMs, and noisy neighbors: the limits of parallelism

Sometimes your program is slow not because of your code, but because of where it’s running. If you have other processes competing for the same limited hardware resources, your code will run more slowly. Once you add virtualization into the mix, those competing processes might be invisible… but they’re still there. In this article we’ll cover: The hardware limits of CPUs’ cores and “hyperthreads”. How operating systems deal with multiple processes that want to use limited number of CPU cores. […]

Read more

Build a URL Shortener With FastAPI and Python

In this tutorial, you’ll build a URL shortener with Python and FastAPI. URLs can be extremely long and not user-friendly. This is where a URL shortener can come in handy. A URL shortener reduces the number of characters in a URL, making it easier to read, remember, and share. By following this step-by-step project, you’ll build a URL shortener with Python and FastAPI. At the end of this tutorial, you’ll have a fully functional API-driven web app that creates shortened […]

Read more
1 94 95 96 97 98 185