Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,110 --> 00:00:05,490
Let's talk about the numbers and math operators in Python.
2
00:00:05,520 --> 00:00:14,370
There are three types of numbers, integers, which are whole numbers flux or floating point numbers
3
00:00:14,370 --> 00:00:21,570
which are positive or negative numbers containing one or more decimals and the complex numbers.
4
00:00:22,620 --> 00:00:29,250
Complex numbers are used in electrical engineering and we want to discuss them in our course.
5
00:00:29,400 --> 00:00:33,330
Instead, we'll focus on integers and floats.
6
00:00:34,470 --> 00:00:35,790
Before going on.
7
00:00:35,790 --> 00:00:37,710
Let's see what an operator is.
8
00:00:38,280 --> 00:00:44,100
An operator is a symbol of the programming language able to operate on various.
9
00:00:45,560 --> 00:00:53,930
There are arithmetic operators, assignment operators, comparison operators, identity operators and
10
00:00:53,930 --> 00:00:55,430
logical operators.
11
00:00:55,760 --> 00:00:57,920
Let's take them one by one.
12
00:00:59,180 --> 00:01:06,170
Or arithmetic operators are used along with numeric values, to perform common mathematical operations.
13
00:01:06,680 --> 00:01:09,980
See the following arithmetic operators.
14
00:01:10,730 --> 00:01:14,570
Addition, subtraction and the division.
15
00:01:14,900 --> 00:01:19,640
For example, print five plus five.
16
00:01:20,000 --> 00:01:21,860
Of course x ten.
17
00:01:22,490 --> 00:01:27,650
This is an addition or a three minus nine.
18
00:01:28,070 --> 00:01:29,870
This is a subtraction.
19
00:01:31,840 --> 00:01:39,940
And the result is minus six and the division eight divided by four.
20
00:01:41,590 --> 00:01:47,860
Note that it returns floating point number even though there is no remainder.
21
00:01:49,740 --> 00:01:55,320
So eight divided by four is two as the float.
22
00:01:55,740 --> 00:02:01,320
There is also the flaw or the integer division which returns an integer.
23
00:02:02,190 --> 00:02:05,850
If there's a reminder, it won't be displayed.
24
00:02:07,380 --> 00:02:08,190
11.
25
00:02:08,940 --> 00:02:11,970
The floor division operator and to.
26
00:02:12,780 --> 00:02:19,020
The quotient will be five and the remainder one which will not be displayed.
27
00:02:20,030 --> 00:02:20,900
So five.
28
00:02:22,790 --> 00:02:25,310
There is also the multiplication.
29
00:02:33,580 --> 00:02:38,260
Double stars is the exponentiation or raising to a power.
30
00:02:39,510 --> 00:02:46,680
For example, let's see the result of two to the power of 100.
31
00:02:49,860 --> 00:02:52,080
And I've got this very big number.
32
00:02:54,570 --> 00:02:58,380
And finally modulus or simply mode.
33
00:02:59,840 --> 00:03:05,690
It returns the remainder of the division of left operand by the right.
34
00:03:08,090 --> 00:03:08,630
Eight.
35
00:03:09,420 --> 00:03:10,320
Mode five.
36
00:03:11,130 --> 00:03:17,580
It will be three because five goes one time in eight and the remainder is three.
37
00:03:22,710 --> 00:03:36,810
And 14 mode four equals two because four goes three times in 14 and there is a remainder of two.
38
00:03:40,120 --> 00:03:47,380
Note that if we use INT and float in a mathematical expression, the result will be a float.
39
00:03:48,590 --> 00:03:51,800
Four times 5.0.
40
00:03:52,630 --> 00:03:55,560
The result will be 20 as a float.
41
00:03:55,570 --> 00:03:57,610
So 20.0.
42
00:03:59,440 --> 00:04:04,590
At the end of this lecture, I'd like to talk about the order of operations.
43
00:04:05,600 --> 00:04:12,860
In mathematics and computer programming, the order of operations or operator Precedence is a collection
44
00:04:12,860 --> 00:04:18,860
of rules that reflects conventions about which operations will be first evaluated.
45
00:04:19,670 --> 00:04:25,040
Exponentiation or raising to a power is at the highest level of precedence.
46
00:04:25,460 --> 00:04:34,550
Multiplication and division are at the lower level of precedence, and the addition and subtraction
47
00:04:34,550 --> 00:04:37,910
are at an even lower level of precedence.
48
00:04:38,870 --> 00:04:40,220
Lexi, an example.
49
00:04:43,310 --> 00:04:45,290
Two plus four.
50
00:04:46,230 --> 00:04:46,710
Pym's.
51
00:04:47,430 --> 00:04:49,380
To the Power of three.
52
00:04:51,360 --> 00:04:54,780
What will be the result of these operations?
53
00:04:55,080 --> 00:04:59,040
Pause the video and think about it for a few seconds.
54
00:04:59,950 --> 00:05:02,860
And the correct answer is 34.
55
00:05:09,440 --> 00:05:16,250
X because the exponentiation has the highest precedence and is evaluated first.
56
00:05:16,940 --> 00:05:19,970
So two to the power of three equals eight.
57
00:05:22,010 --> 00:05:24,890
The multiplication comes next.
58
00:05:24,890 --> 00:05:29,390
And that means four times eight equals 32.
59
00:05:32,730 --> 00:05:36,840
And finally, the addition will have the lowest precedence level.
60
00:05:37,820 --> 00:05:41,060
Two plus 32 equals 34.
61
00:05:47,850 --> 00:05:52,110
If you want to change the order of operations, you use parentheses.
62
00:05:52,320 --> 00:05:58,980
In the next example, I want the addition to be evaluated first and I'll use parentheses.
63
00:06:05,860 --> 00:06:13,600
Now the final result will be six times eight equals 48.
64
00:06:18,510 --> 00:06:19,620
X 48.
65
00:06:22,560 --> 00:06:25,900
You can't use square brackets or curly braces.
66
00:06:25,920 --> 00:06:33,300
Only parentheses if you use curly braces or square brackets instead of parentheses.
67
00:06:33,520 --> 00:06:34,980
You'll get something else.
68
00:06:48,550 --> 00:06:51,660
At the end of this video, I'll show you a trick.
69
00:06:52,170 --> 00:06:56,400
If you have a large numeric value like this one.
70
00:06:58,730 --> 00:07:01,730
It's probably difficult for you to read it.
71
00:07:02,270 --> 00:07:03,620
Is there a million?
72
00:07:03,620 --> 00:07:06,440
10 million, a billion or something else?
73
00:07:06,950 --> 00:07:13,640
Normally you'd use commas or docs to separate every three decimal places.
74
00:07:13,760 --> 00:07:20,300
You'd use commas in the US and the UK, and that's in the other European countries.
75
00:07:22,630 --> 00:07:23,620
In Python.
76
00:07:23,620 --> 00:07:31,570
You can use underscores as visual separators for digit grouping purposes in integers or floating point
77
00:07:31,570 --> 00:07:32,290
numbers.
78
00:07:33,280 --> 00:07:34,690
For readability.
79
00:07:34,690 --> 00:07:37,030
You could write the number like this.
80
00:07:43,640 --> 00:07:51,680
The underscores have no semantic meaning and the numbers are parsed is if the underscores were absent.
81
00:07:56,730 --> 00:08:00,120
X 1,000,001,000.
82
00:08:01,000 --> 00:08:07,540
Equals C equals one underscore 000e to return true.
83
00:08:09,780 --> 00:08:14,100
The underscore in this number has no significance.
84
00:08:14,610 --> 00:08:17,730
We are done with numbers and math operators.
85
00:08:17,880 --> 00:08:22,770
So up next, we are going to have a quick quiz about what you've learned so far.
86
00:08:23,220 --> 00:08:29,880
Good luck with the quiz and I'll see you in the next video where we'll go over all of the assignment
87
00:08:29,880 --> 00:08:30,790
operators.
88
00:08:30,810 --> 00:08:31,560
Bye bye.
7724
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.