Category: New Python tutorial

python tutorials and learn python

Created with Sketch.

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

Python Float to Int

Python Float to Int Summary: in this tutorial, you’ll learn how to convert a float to an integer. Suppose that you have a float such as 20.3, and you want to convert it to an integer. When you convert a float to an integer, you’ll have a data loss. For example, 20.3 may become 20…
Read more

Python float

Python float Summary: in this tutorial, you’ll learn about the Python float type, how Python represents floating-point numbers, and how to test the floating-point number for equality. Introduction to the Python float type Python uses the float class to represent real numbers. CPython implements float using C double type. The C double type usually implements…
Read more

Python or Operator

Python or Operator Summary: in this tutorial, you’ll learn about the Python or operator and how to use it effectively. Introduction to the Python or operator The or the operator is a logical operator. Typically, you use the or operator to combine two Boolean expressions and return a Boolean value. The or the operator returns…
Read more

Python and Operator

Python and Operator Summary: in this tutorial, you’ll learn about the Python and logical operator and how to use it to control the flow of code. Introduction to the Python and operator The Python and operator is a logical operator. Typically, you use the and operator to operate on Boolean values and return a Boolean…
Read more