valeur absolue python

>>> x = - 3
>>> abs(x)
3

Here is what the above code is Doing:
1. We are creating a variable called x and assigning it the value -3.
2. We are using the abs() function to find the absolute value of x.
3. We are printing the result of the abs() function.

As you can see, the abs() function returns the absolute value of a number.

Let’s look at another example:

>>> x = 3.14
>>> abs(x)
3.14

In this example, we are creating a variable called x and assigning it the value 3.14. We are then using the abs() function to find the absolute value of x. As you can see, the abs() function returns the absolute value of a number.

Now, let’s try to use the abs() function with a complex number:

>>> x = 3 + 4j
>>> abs(x)
5.0

As you can see, the abs() function returns the absolute value of a complex number.

Great job! In the next lesson, we’ll learn about the all() function.