1
00:00:00,009 --> 00:00:02,380
Let's talk about some more operators and

2
00:00:02,390 --> 00:00:05,019
starting off with the arithmetic operations.

3
00:00:05,030 --> 00:00:06,099
And this is just like,

4
00:00:06,599 --> 00:00:06,840
you know,

5
00:00:06,849 --> 00:00:12,109
the mathematics or basic mathematics that we learned back when we were kids, right?

6
00:00:12,119 --> 00:00:12,470
So

7
00:00:12,739 --> 00:00:18,709
you have, you know, one times 12 times 23 plus 1, 10 minus seven, that kind of thing,

8
00:00:18,719 --> 00:00:18,989
right?

9
00:00:19,000 --> 00:00:19,270
So

10
00:00:19,559 --> 00:00:23,340
what I've done here is I've assigned the value of 10 to variable A

11
00:00:23,540 --> 00:00:27,139
and the value of three to variable B.

12
00:00:27,329 --> 00:00:30,559
And I've written out several arithmetic operations. In here,

13
00:00:30,799 --> 00:00:35,950
we have A plus B A minus B A times B A divided by B

14
00:00:36,119 --> 00:00:38,069
A modulus B

15
00:00:38,229 --> 00:00:40,630
which will simply return the remainder

16
00:00:40,779 --> 00:00:43,259
when we divide A by B.

17
00:00:43,669 --> 00:00:50,959
And then the last one here is going to be a exponential B which will raise the value of A

18
00:00:51,299 --> 00:00:53,939
by the power of B.

19
00:00:54,060 --> 00:00:54,689
So

20
00:00:54,919 --> 00:00:56,889
what are the results here going to be?

21
00:00:56,900 --> 00:01:01,889
Let me run the program and of course, 10 plus three is 1310 minus three is 7,

22
00:01:01,900 --> 00:01:06,309
10 times three is 3010 divided by three will be 3.3333

23
00:01:06,330 --> 00:01:09,730
and then 10 with the loss three will be one.

24
00:01:09,949 --> 00:01:10,830
And of course,

25
00:01:11,080 --> 00:01:14,610
10 times 10 times 10 will be equal to

26
00:01:14,940 --> 00:01:17,449
1000 right? OK.

27
00:01:17,459 --> 00:01:22,010
So I expect that you obviously knew the answers to all of these operations.

28
00:01:22,360 --> 00:01:27,529
But let's go further, I'm going to remove this. OK? And

29
00:01:27,870 --> 00:01:30,529
I do have some more operations in here.

30
00:01:31,419 --> 00:01:32,800
And the first one in here

31
00:01:33,120 --> 00:01:37,599
is what we call an assignment operator. You can see right there, it says

32
00:01:38,029 --> 00:01:41,040
plus equals right. Let me

33
00:01:42,040 --> 00:01:43,819
add this in new lines

34
00:01:44,879 --> 00:01:46,480
and there you go. OK?

35
00:01:46,790 --> 00:01:53,940
So we have plus equals what this simply means is that we

36
00:01:54,550 --> 00:01:58,669
are going to say X equals X plus five.

37
00:01:59,169 --> 00:02:00,569
It's basically the same thing.

38
00:02:00,580 --> 00:02:06,370
So X plus equals five is, is the exact same thing as an X equals Xr plus five.

39
00:02:06,470 --> 00:02:09,210
This is just a short form of writing this.

40
00:02:09,449 --> 00:02:09,940
So

41
00:02:10,110 --> 00:02:11,990
let me just go ahead and remove this.

42
00:02:12,279 --> 00:02:14,330
So what do you think the answer here would be the answer?

43
00:02:14,339 --> 00:02:19,800
Obviously, here is going to be 15 because 10 plus five equals 15.

44
00:02:19,839 --> 00:02:24,789
Now you can do the opposite. OK? You can say minus and then equals

45
00:02:24,910 --> 00:02:30,149
the answer here obviously would be five because 10 minus five will be five

46
00:02:30,320 --> 00:02:32,809
and you have other ones of course, like the

47
00:02:33,729 --> 00:02:34,979
a multiplication

48
00:02:35,440 --> 00:02:37,830
which will give us a 50.

49
00:02:38,320 --> 00:02:40,440
And then we also have the division

50
00:02:40,600 --> 00:02:43,869
which will give us a 22 point. Oh So

51
00:02:44,000 --> 00:02:47,720
these are what we call the assignment operators.

52
00:02:47,860 --> 00:02:48,270
Now,

53
00:02:48,279 --> 00:02:51,279
I want to draw your attention to one more thing

54
00:02:51,289 --> 00:02:54,600
and this is what we call the operator precedence.

55
00:02:54,729 --> 00:02:56,190
Let me, first of all, remove

56
00:02:56,570 --> 00:02:57,789
the code

57
00:02:59,119 --> 00:03:01,580
and let me drag this to the top

58
00:03:02,589 --> 00:03:04,929
and print on a new line.

59
00:03:05,419 --> 00:03:06,679
Let me copy

60
00:03:07,100 --> 00:03:10,330
this command and come down here

61
00:03:10,720 --> 00:03:11,960
and then print. All right.

62
00:03:12,169 --> 00:03:12,649
So

63
00:03:12,789 --> 00:03:15,270
take a look at this. OK? We have two different expressions. All right.

64
00:03:15,279 --> 00:03:16,639
The first one here says

65
00:03:16,960 --> 00:03:20,050
two plus three times four.

66
00:03:20,539 --> 00:03:26,130
Well, the second one here is we have our brackets two plus three and then times four,

67
00:03:26,699 --> 00:03:30,119
what do you think the results of both expressions are going to be?

68
00:03:30,130 --> 00:03:32,889
Again, this might remind you of the math that you did back in,

69
00:03:32,949 --> 00:03:36,550
in your kindergarten or primary school days.

70
00:03:36,899 --> 00:03:39,330
But I always find this quite fascinating because

71
00:03:39,500 --> 00:03:41,649
here we're going to get two different results.

72
00:03:41,770 --> 00:03:43,679
So you can pause the video and try to

73
00:03:43,690 --> 00:03:46,750
guess what the results of both expressions would be.

74
00:03:46,990 --> 00:03:48,279
If you have your results,

75
00:03:48,750 --> 00:03:51,380
let's go ahead right now and run.

76
00:03:51,759 --> 00:03:54,179
And the first one here will be 14

77
00:03:54,339 --> 00:03:56,860
while the second will be 20.

78
00:03:57,020 --> 00:03:58,220
Why?

79
00:03:58,470 --> 00:04:01,089
Because on the first expression in here, we have two

80
00:04:01,440 --> 00:04:05,350
operators, we have the plus arithmetic operator

81
00:04:05,669 --> 00:04:07,500
and then we have the multiplication.

82
00:04:07,809 --> 00:04:13,539
Python will do the multiplication first before the addition. So

83
00:04:13,779 --> 00:04:18,980
three times four is going to be 1212 plus two is gonna be equal to 14.

84
00:04:19,269 --> 00:04:22,489
However, over here in the second expression,

85
00:04:22,790 --> 00:04:25,070
it's actually going to do

86
00:04:25,380 --> 00:04:30,579
the addition first because they're inside of brackets,

87
00:04:30,959 --> 00:04:31,779
that's why?

88
00:04:32,399 --> 00:04:35,500
So unless I'm mistaken, typically it is,

89
00:04:35,510 --> 00:04:39,779
you will have the parenthesis will be at the very top of the precedent.

90
00:04:40,070 --> 00:04:43,769
If you don't have the parenthesis, it will check for exponentiation.

91
00:04:44,119 --> 00:04:47,380
If there isn't any exponentiation, then it will go to multiplication,

92
00:04:47,470 --> 00:04:50,040
it will go to division, it will go to model loss

93
00:04:50,149 --> 00:04:52,809
addition and then finally subtraction.

94
00:04:53,339 --> 00:04:53,980
And then

95
00:04:54,250 --> 00:04:57,929
in a very complex expression, if you do have a comparison operators,

96
00:04:57,940 --> 00:04:58,700
those will come next.

97
00:04:58,709 --> 00:04:59,609
And then finally,

98
00:04:59,769 --> 00:05:01,700
logical operators, but

99
00:05:02,209 --> 00:05:04,739
no need to go any further than that over here,

100
00:05:04,929 --> 00:05:10,070
we simply have two main operators or whatever we have three, we have the parentheses

101
00:05:10,459 --> 00:05:14,450
which of course will take precedence over the multiplication.

102
00:05:14,459 --> 00:05:17,510
So two plus three is 55, multiplied by four

103
00:05:17,630 --> 00:05:21,579
equals 20. So once again, this is what we call the operator

104
00:05:21,709 --> 00:05:22,799
precedence.

105
00:05:23,260 --> 00:05:25,950
Again, to be honest, we're not really going to be working with these

106
00:05:26,589 --> 00:05:26,619
in

107
00:05:26,769 --> 00:05:30,880
this course. But nevertheless, this is something that you should be aware of.

108
00:05:30,890 --> 00:05:33,010
Thank you for watching. I will see you in the next class.

