Python tutorials

Variables in Python: Usage and Best Practices

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: Variables in Python In Python, variables are symbolic names that refer to objects or values stored in your computer’s memory. They allow you to assign descriptive names to data, making it easier to manipulate and reuse values throughout your code. Understanding variables is key for Python developers because variables are essential building blocks for […]

Read more

The Python Square Root Function

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: The Square Root Function in Python The Python square root function, sqrt(), is part of the math module and is used to calculate the square root of a given number. To use it, you import the math module and call math.sqrt() with a non-negative number as an argument. For example, math.sqrt(9) returns 3.0. This […]

Read more

Quiz: Using .__repr__() vs .__str__() in Python

Interactive Quiz ⋅ 6 QuestionsBy Martin Breuss Share In this quiz, you’ll test your understanding of Python’s .__repr__() and .__str__() special methods. These methods allow you to control how a program displays an object, making your classes more readable and easier to debug and maintain. The quiz contains 6 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%. […]

Read more

Python Closures: Common Use Cases and Examples

In Python, a closure is typically a function defined inside another function. This inner function grabs the objects defined in its enclosing scope and associates them with the inner function object itself. The resulting combination is called a closure. Closures are a common feature in functional programming languages. In Python, closures can be pretty useful because they allow you to create function-based decorators, which are powerful tools. In this tutorial, you’ll: Learn what closures are and how they work in […]

Read more

Python’s Magic Methods in Classes

As a Python developer who wants to harness the power of object-oriented programming, you’ll love to learn how to customize your classes using special methods, also known as magic methods or dunder methods. A special method is a method whose name starts and ends with a double underscore. These methods have special meanings in Python. Python automatically calls magic methods as a response to certain operations, such as instantiation, sequence indexing, attribute managing, and much more. Magic methods support core […]

Read more

Quiz: Beautiful Soup: Build a Web Scraper With Python

Interactive Quiz ⋅ 14 QuestionsBy Martin Breuss Share In this quiz, you’ll test your understanding of web scraping with Python, Requests, and Beautiful Soup. By working through this quiz, you’ll revisit how to inspect the HTML structure of your target site with your browser’s developer tools, decipher data encoded in URLs, use Requests and Beautiful Soup for scraping and parsing data from the Web, and gain an understanding of what a web scraping pipeline looks like. The quiz contains 14 […]

Read more

Quiz: The Python Standard REPL: Try Out Code and Ideas Quickly

Interactive Quiz ⋅ 11 QuestionsBy Leodanis Pozo Ramos Share In this quiz, you’ll test your understanding of The Python Standard REPL: Try Out Code and Ideas Quickly. The Python REPL allows you to run Python code interactively, which is useful for testing new ideas, exploring libraries, refactoring and debugging code, and trying out examples. 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 […]

Read more

Quiz: How to Reset a pandas DataFrame Index

Interactive Quiz ⋅ 10 QuestionsBy Ian Eyre Share In this quiz, you’ll test your understanding of how to reset a pandas DataFrame index. By working through the questions, you’ll review your knowledge of indexing and also expand on what you learned in the tutorial. You’ll need to do some research outside of the tutorial to answer all the questions. Embrace this challenge and let it take you on a learning journey. The quiz contains 10 questions and there is no […]

Read more

Quiz: Python Class Constructors: Control Your Object Instantiation

Interactive Quiz ⋅ 9 QuestionsBy Martin Breuss Share In this quiz, you’ll test your understanding of Python Class Constructors. By working through this quiz, you’ll revisit the internal instantiation process, object initialization using .__init__(), and fine-tuning object creation by overriding .__new__(). The quiz contains 9 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

Quiz: Defining Your Own Python Function

Interactive Quiz ⋅ 18 QuestionsBy Martin Breuss Share In this quiz, you’ll test your understanding of how to define your own Python function. You’ll revisit theoretical knowledge about passing values to functions, when to divide your program into separate user-defined functions, and all the tools you’ll need to define complex and powerful functions in Python. The quiz contains 18 questions and there is no time limit. You’ll get 1 point for each correct answer. At the end of the quiz, […]

Read more
1 2 3 4 5 6 182