Let's talk about the numbers and math operators in Python.
There are three types of numbers, integers, which are whole numbers flux or floating point numbers
which are positive or negative numbers containing one or more decimals and the complex numbers.
Complex numbers are used in electrical engineering and we want to discuss them in our course.
Instead, we'll focus on integers and floats.
Before going on.
Let's see what an operator is.
An operator is a symbol of the programming language able to operate on various.
There are arithmetic operators, assignment operators, comparison operators, identity operators and
logical operators.
Let's take them one by one.
Or arithmetic operators are used along with numeric values, to perform common mathematical operations.
See the following arithmetic operators.
Addition, subtraction and the division.
For example, print five plus five.
Of course x ten.
This is an addition or a three minus nine.
This is a subtraction.
And the result is minus six and the division eight divided by four.
Note that it returns floating point number even though there is no remainder.
So eight divided by four is two as the float.
There is also the flaw or the integer division which returns an integer.
If there's a reminder, it won't be displayed.
11.
The floor division operator and to.
The quotient will be five and the remainder one which will not be displayed.
So five.
There is also the multiplication.
Double stars is the exponentiation or raising to a power.
For example, let's see the result of two to the power of 100.
And I've got this very big number.
And finally modulus or simply mode.
It returns the remainder of the division of left operand by the right.
Eight.
Mode five.
It will be three because five goes one time in eight and the remainder is three.
And 14 mode four equals two because four goes three times in 14 and there is a remainder of two.
Note that if we use INT and float in a mathematical expression, the result will be a float.
Four times 5.0.
The result will be 20 as a float.
So 20.0.
At the end of this lecture, I'd like to talk about the order of operations.
In mathematics and computer programming, the order of operations or operator Precedence is a collection
of rules that reflects conventions about which operations will be first evaluated.
Exponentiation or raising to a power is at the highest level of precedence.
Multiplication and division are at the lower level of precedence, and the addition and subtraction
are at an even lower level of precedence.
Lexi, an example.
Two plus four.
Pym's.
To the Power of three.
What will be the result of these operations?
Pause the video and think about it for a few seconds.
And the correct answer is 34.
X because the exponentiation has the highest precedence and is evaluated first.
So two to the power of three equals eight.
The multiplication comes next.
And that means four times eight equals 32.
And finally, the addition will have the lowest precedence level.
Two plus 32 equals 34.
If you want to change the order of operations, you use parentheses.
In the next example, I want the addition to be evaluated first and I'll use parentheses.
Now the final result will be six times eight equals 48.
X 48.
You can't use square brackets or curly braces.
Only parentheses if you use curly braces or square brackets instead of parentheses.
You'll get something else.
At the end of this video, I'll show you a trick.
If you have a large numeric value like this one.
It's probably difficult for you to read it.
Is there a million?
10 million, a billion or something else?
Normally you'd use commas or docs to separate every three decimal places.
You'd use commas in the US and the UK, and that's in the other European countries.
In Python.
You can use underscores as visual separators for digit grouping purposes in integers or floating point
numbers.
For readability.
You could write the number like this.
The underscores have no semantic meaning and the numbers are parsed is if the underscores were absent.
X 1,000,001,000.
Equals C equals one underscore 000e to return true.
The underscore in this number has no significance.
We are done with numbers and math operators.
So up next, we are going to have a quick quiz about what you've learned so far.
Good luck with the quiz and I'll see you in the next video where we'll go over all of the assignment
operators.
Bye bye.