Blog

python tutorials and learn python

Created with Sketch.

Python Sequences

Python Sequences Summary: in this tutorial, you’ll learn about the Python sequences and their basic operations. Introduction to Python sequences A sequence is a positionally ordered collection of items. And you can refer to any item in the sequence by using its index number e.g., s[0] and s[1]. In Python, the sequence index starts at…
Read more

Python NamedTuple

Python NamedTuple Summary: in this tutorial, you’ll learn how to use the Python namedtuple function to create named tuples. Introduction to Python named tuples The following shows a tuple that has two elements: point = (100,200) Code language: Python (python) The point tuple represents a 2D point whose x-coordinate is 100 and y coordinate is…
Read more

Python Class Decorators

Python Class Decorators Summary: in this tutorial, you’ll learn about Python class decorators. After the tutorial, you’ll know how to define classes as decorators. Introduction to the Python class decorators So far you have learned how to use functions to define decorators. For example, the following star function prints out a number of * characters…
Read more

Python Decorator with Arguments

Python Decorator with Arguments Summary: in this tutorial, you’ll learn how to define Python decorators with arguments using a decorator factory. Introduction to Python decorator with arguments Suppose that you have a function called say that prints out a message: def say(message): ”’ print the message Arguments message: the message to show ”’ print(message) Code…
Read more

Python Decorators

Python Decorators Summary: in this tutorial, you’ll learn about Python decorators and how to develop your own decorators. What is a decorator in Python? A decorator is a function that takes another function as an argument and extends its behavior without changing the original function explicitly. Let’s take a simple example to understand the concept.…
Read more

Python Closures

Python Closures Summary: in this tutorial, you’ll learn about Python closures and their practical applications. Introduction to the Python closures In Python, you can define a function from the inside of another function. And this function is called a nested function. For example: def say(): greeting = ‘Hello’ def display(): print(greeting) display() Code language: Python…
Read more

Python nonlocal

Python nonlocal Summary: in this tutorial, you’ll learn about the Python nonlocal scopes and how to use the nonlocal keyword to change the variables of the nonlocal scopes. Introduction to Python nonlocal scopes In Python, you can define a function inside another function. For example: def outer(): print(‘outer function’)def inner(): print(‘inner function’) inner() outer() Code…
Read more

Python Variable Scopes

Python Variable Scopes Summary: in this tutorial, you’ll learn how Python variable scopes work. After the tutorial, you’ll have a good understanding of built-in, local, and global scopes. Introduction to Python variable scopes When you assign an object to a variable, the variable will reference that object in the memory. And it’s saying that the…
Read more

Python Decimal

Python Decimal Summary: in this tutorial, you’ll learn about the Python decimal module that supports fast correctly-rounded decimal floating-point arithmetic. Introduction to the Python decimal module Many decimal numbers don’t have exact representations in binary floating-point such as 0.1. When using these numbers in arithmetic operations, you’ll get a result that you would not expect.…
Read more

Python Rounding

Python Rounding Summary: in this tutorial, you’ll learn how to use the Python round() function to round a number. Introduction to the Python round() function Rounding means making a number simpler but keeping its value close to its original value. For example, 89 rounded to the nearest ten is 90 because 89 is closer to…
Read more