1 00:00:00,000 --> 00:00:01,200 [no audio] 2 00:00:01,200 --> 00:00:02,200 Friends, here 3 00:00:02,200 --> 00:00:06,500 We are going to discuss the first two operators of your Python. 4 00:00:06,700 --> 00:00:10,100 They are arithmetic and assignment operators. First 5 00:00:10,100 --> 00:00:12,700 let me go with your arithmetic operators. 6 00:00:13,200 --> 00:00:16,700 See we have different types of arithmetic operators. 7 00:00:17,100 --> 00:00:19,700 They are like, you know already we know in your mathematics - 8 00:00:19,700 --> 00:00:24,600 addition, subtraction, multiplication, division, modulo. 9 00:00:25,500 --> 00:00:28,600 Right. So here floor division is somewhat a new one, 10 00:00:28,600 --> 00:00:33,200 we will see that, and then exponential. So these all are 11 00:00:33,200 --> 00:00:35,500 your arithmetic operators, right. 12 00:00:36,000 --> 00:00:39,000 Let me open my Python terminal. There 13 00:00:39,000 --> 00:00:40,900 I can easily explain about them. 14 00:00:40,900 --> 00:00:43,000 [no audio] 15 00:00:43,000 --> 00:00:45,900 Let me enter into my Python terminal, Python command line, or 16 00:00:45,900 --> 00:00:46,900 Python Shell. 17 00:00:47,400 --> 00:00:50,000 So guys, directly I can do suppose 2 + 2, 18 00:00:50,700 --> 00:00:53,900 I mean any number you can take, not only 2 + 2, some 19 00:00:53,900 --> 00:00:55,900 4 + 2, right. 20 00:00:56,600 --> 00:00:59,700 So this is just to perform addition of two values. 21 00:01:01,000 --> 00:01:04,300 Right. So I can store this result into some variable as well. 22 00:01:04,400 --> 00:01:07,700 Let's say 'result=', or we can take any variable, addition 23 00:01:07,700 --> 00:01:10,900 of two numbers, something like that or simply 'sum=', 24 00:01:10,900 --> 00:01:16,200 or 's='. Variable is your wish, right. Now just print your 's'. 25 00:01:16,800 --> 00:01:20,000 Yes, you are getting. Right. Not only like that, 26 00:01:20,100 --> 00:01:24,800 just you can store your values in some variables. 27 00:01:25,800 --> 00:01:30,600 And let me take 'c= a + b', and then print your 'c'. 28 00:01:32,000 --> 00:01:36,300 So likewise, you can do your subtraction, multiplication, right? 29 00:01:36,300 --> 00:01:40,500 Let me do one thing, 'c = a - b'. 30 00:01:40,600 --> 00:01:43,900 So 'a' is 4, and 'b=8', the result is -4. 31 00:01:45,100 --> 00:01:48,200 Now let's say 'c = a * b' 32 00:01:49,100 --> 00:01:51,100 Now 'c' is 32. 33 00:01:52,600 --> 00:01:56,600 Right. Now, let me do one more thing 'c= 34 00:01:57,700 --> 00:02:03,200 if I take 4/8, right result is 0.5. 35 00:02:03,200 --> 00:02:05,500 [no audio] 36 00:02:05,500 --> 00:02:08,900 You know, right 4/8 result is, otherwise you just 37 00:02:08,900 --> 00:02:11,000 do 8/4. 38 00:02:12,699 --> 00:02:15,000 Then see the result, 2.0. 39 00:02:16,700 --> 00:02:19,900 Okay. See guys, by default you are getting your result 40 00:02:20,500 --> 00:02:21,800 in terms of float. 41 00:02:22,300 --> 00:02:26,600 So this is with your Python 3, but if you go with Python 2 42 00:02:26,600 --> 00:02:29,300 if any one of the value is 43 00:02:29,300 --> 00:02:31,400 [no audio] 44 00:02:31,400 --> 00:02:33,200 float, then only 45 00:02:33,200 --> 00:02:34,800 you will get result as float number. 46 00:02:36,300 --> 00:02:40,100 Right. Anyway, we are working with Python 3.x, right and we 47 00:02:40,100 --> 00:02:42,700 know this is the future version. 48 00:02:43,500 --> 00:02:48,600 I mean from 2020 we have to use this one, right. Fine. 49 00:02:49,800 --> 00:02:53,000 Now, let me do, don't worry about this line guys. 50 00:02:53,000 --> 00:02:54,700 Just I am going to clear my screen. 51 00:02:54,700 --> 00:02:58,500 [no audio] 52 00:02:58,500 --> 00:03:04,500 Fine. Now, exponential. Suppose if I want to find something 53 00:03:04,500 --> 00:03:09,700 like 3² or some 4³, how you can find. 54 00:03:10,600 --> 00:03:15,800 See 3², you can write 3**2. Now this 55 00:03:15,800 --> 00:03:19,900 is nothing but 3². The result is 9. Of course, you can 56 00:03:19,900 --> 00:03:22,900 store your values into, let's say 'a=5', and 57 00:03:22,900 --> 00:03:29,100 'b=3'. Now if I want to find a^5, a*, sorry 58 00:03:29,500 --> 00:03:32,100 a^b or 5³ 59 00:03:32,100 --> 00:03:34,500 [no audio] 60 00:03:34,500 --> 00:03:36,600 or 5³, right, a³. 61 00:03:36,600 --> 00:03:38,800 I can do either in this way or this way. 62 00:03:39,000 --> 00:03:40,800 Just after the result, 125. 63 00:03:42,000 --> 00:03:45,300 I can store that into some variable called 'result', or any 64 00:03:45,300 --> 00:03:51,900 variable. Let's say, a**b. Now simply print your 65 00:03:51,900 --> 00:03:53,200 'result', and see the value. 66 00:03:53,200 --> 00:03:57,500 [no audio] 67 00:03:57,500 --> 00:04:00,800 Right. Now if you observe we covered all the operations, 68 00:04:00,800 --> 00:04:03,700 yeah, we have pending with modulo and then we'll see 69 00:04:03,700 --> 00:04:05,600 floor division. So modulo. 70 00:04:05,600 --> 00:04:08,600 Let me take some number guys. Suppose 71 00:04:08,600 --> 00:04:12,300 I am going to take some 7, if I want to divide this with 72 00:04:12,300 --> 00:04:14,500 2. 2*3, just 6. Now 73 00:04:14,500 --> 00:04:20,000 what is the remainder value, 1. Right. Now see what I am doing 74 00:04:20,000 --> 00:04:28,900 is 7%2, result is 1. Likewise suppose if you 75 00:04:28,900 --> 00:04:32,000 divide 8 with 2, then what is the remainder? 76 00:04:32,000 --> 00:04:34,600 So 8%2 is always 0, we know that. 77 00:04:35,900 --> 00:04:37,300 Just to find your reminder 78 00:04:37,900 --> 00:04:41,000 you're using '%' symbol. Then the last one is 79 00:04:41,000 --> 00:04:47,400 floor division, right. See that. Right. Nothing is there. Just take two 80 00:04:47,400 --> 00:04:51,700 times your '/', or division symbol. See the result. 4, right. 81 00:04:51,700 --> 00:04:54,700 Now what I'm doing is, now see the 'result'. 82 00:04:56,000 --> 00:05:01,000 By default if you take 7 by 2 what you were getting, 3.5. 83 00:05:02,200 --> 00:05:03,500 If you do floor division, 84 00:05:03,500 --> 00:05:05,300 [no audio] 85 00:05:05,300 --> 00:05:08,200 right, if you do floor division. See, 86 00:05:09,300 --> 00:05:12,700 yeah, simply assume that in this output only, in this explanation 87 00:05:14,300 --> 00:05:15,500 two threes are six, 88 00:05:15,500 --> 00:05:17,500 [no audio] 89 00:05:17,500 --> 00:05:20,300 reminder 1. Your quotient is 3. You 90 00:05:20,300 --> 00:05:23,700 will get this pure quotient without your floating points. 91 00:05:25,600 --> 00:05:30,400 Right, and that too you can assume 3.5 actually, no. 7/6, or 92 00:05:30,500 --> 00:05:33,500 if you do your 7 93 00:05:35,100 --> 00:05:36,400 reminder 2. What is the value? 94 00:05:37,000 --> 00:05:42,400 Sorry, 7/2, what is the value? 3.5. Then if you round off 95 00:05:42,400 --> 00:05:47,300 that value to lower value then the result is 3. So that 96 00:05:47,300 --> 00:05:48,000 is what you are getting. 97 00:05:48,000 --> 00:05:51,000 [no audio] 98 00:05:51,000 --> 00:05:52,800 Let's say 9. 99 00:05:53,700 --> 00:05:56,500 Let's say -9//2. 100 00:05:57,900 --> 00:06:00,200 See what you are going to get. You're going to get -5 101 00:06:00,600 --> 00:06:06,500 because 9/2 is almost 4.5, -4.5. 102 00:06:07,900 --> 00:06:09,600 Right. See in your number system 103 00:06:09,600 --> 00:06:11,800 this is -5, then -4. 104 00:06:12,500 --> 00:06:16,200 So compared to -4, -5 is the lower value. Now, whatever 105 00:06:16,200 --> 00:06:18,700 the result you are getting for that result 106 00:06:18,700 --> 00:06:22,700 you are getting round of value that to lowest round of value. 107 00:06:22,900 --> 00:06:27,700 That's why I -4.5 round of value as a lower value is 108 00:06:27,700 --> 00:06:29,600 always -5. That's what you are getting here. 109 00:06:30,000 --> 00:06:32,200 So that is the uses of your floor division. 110 00:06:32,200 --> 00:06:34,000 [no audio] 111 00:06:34,000 --> 00:06:35,600 Right. Fine. 112 00:06:36,800 --> 00:06:40,200 Then next one is, assignment operator. See already 113 00:06:40,200 --> 00:06:42,600 we know one of the assignment operator like if I 114 00:06:42,600 --> 00:06:44,200 write 'x=2', what you are doing? 115 00:06:44,200 --> 00:06:46,200 [no audio] 116 00:06:46,200 --> 00:06:48,300 2 value you are assigning to 'x'. 117 00:06:48,300 --> 00:06:50,300 [no audio] 118 00:06:50,300 --> 00:06:55,400 Okay. Suppose I can do 'x = 2 + 4', then guys 119 00:06:55,400 --> 00:06:58,500 whenever you have a '=' symbol here, '=' operator here, 120 00:06:58,700 --> 00:07:02,300 for this '=' operator always the right side whatever you 121 00:07:02,300 --> 00:07:05,700 have that expression will be evaluated first, 122 00:07:06,600 --> 00:07:08,500 then that result will be assigned to 'x'. 123 00:07:10,000 --> 00:07:13,200 See, whatever the expression you have with the help of '=' 124 00:07:13,200 --> 00:07:16,900 symbol, let's say 'x=3x + 2' 125 00:07:16,900 --> 00:07:18,800 [no audio] 126 00:07:18,800 --> 00:07:20,400 Assume 'x' equals to some 3 value. 127 00:07:21,600 --> 00:07:24,100 So your Python don't bother about here 'x' is there, here 'x' 128 00:07:24,100 --> 00:07:26,700 is there. Your Python don't bother about that first. 129 00:07:26,700 --> 00:07:30,700 It will take '=' symbol, then it will forget about this. 130 00:07:31,200 --> 00:07:35,300 Whatever is there on right side, first that value will be evaluated, 131 00:07:35,300 --> 00:07:37,500 and that result will be assigned to this variable. 132 00:07:38,100 --> 00:07:42,000 So 'x' is 3. 3 * 3, 9. 9 + 2 is 11. 11 133 00:07:42,000 --> 00:07:46,100 will be assigned to 'x'. If you want to get that result from your command 134 00:07:46,100 --> 00:07:51,400 line, let me take 'x=3'. Then I am writing 135 00:07:51,400 --> 00:07:58,400 'x=x*3', or '3x', '+', some 2. Now see the result 'x' value. 136 00:07:58,400 --> 00:08:00,300 11, right? 137 00:08:00,400 --> 00:08:03,100 So that is simply assignment operator or your '=' symbol is 138 00:08:03,100 --> 00:08:09,100 basically an assignment operator, but see whenever if you 139 00:08:09,100 --> 00:08:10,800 write 'a=a+b', 140 00:08:10,800 --> 00:08:13,500 [no audio] 141 00:08:13,500 --> 00:08:17,400 and observe that here 'a' is there, here also 'a' is there. So in this 142 00:08:17,400 --> 00:08:20,600 case instead of writing your expression, lengthy expression, 143 00:08:20,600 --> 00:08:23,800 you can also write as a shortcut expression as in this way 144 00:08:23,800 --> 00:08:24,800 'a+=b'. 145 00:08:24,800 --> 00:08:27,300 [no audio] 146 00:08:27,300 --> 00:08:28,800 Not only for this, if you observe 147 00:08:28,800 --> 00:08:33,000 all these things, right, see 'a' is there, 'a' is there, 'a' is there, 'a' 148 00:08:33,000 --> 00:08:36,200 is there, so on both the sides for your '=' symbol whenever 149 00:08:36,200 --> 00:08:40,200 if you have 'a', right, then at the time what you 150 00:08:40,200 --> 00:08:44,299 can do is just remove this 'a', and then write '+' before 151 00:08:44,299 --> 00:08:45,200 your '=' symbol. 152 00:08:46,400 --> 00:08:46,409 Right. That's what I did here. 153 00:08:46,409 --> 00:08:48,900 [no audio] 154 00:08:48,900 --> 00:08:53,400 Now these both, two expressions are going to give same result. 155 00:08:54,100 --> 00:08:57,200 So if you want to get the proof just open your terminal. 156 00:08:57,700 --> 00:09:02,300 So here let me take initially 'a=' some 2, and 'b=' 157 00:09:02,300 --> 00:09:06,700 some 3 value. If I write 'a=a+b', what 158 00:09:06,700 --> 00:09:10,400 is the result? Just observe that. 5. Now, I am going to reassign 159 00:09:10,400 --> 00:09:12,400 'a=2', and then 'b=3'. 160 00:09:12,500 --> 00:09:16,400 Now, what I am doing is 'a+=b' and see the result. 161 00:09:17,000 --> 00:09:18,600 That means if you write 162 00:09:18,900 --> 00:09:22,700 either this expression or shortcut expression both will give 163 00:09:22,700 --> 00:09:23,700 same result. 164 00:09:23,700 --> 00:09:26,500 [no audio] 165 00:09:26,500 --> 00:09:31,200 Right. So these are all the assignment operators, and about your 166 00:09:31,200 --> 00:09:33,500 arithmetic operators as well, okay. 167 00:09:35,200 --> 00:09:39,400 Okay, and one more thing, so guys, suppose if you want to define 168 00:09:39,400 --> 00:09:41,700 a simple arithmetic calculator. 169 00:09:42,000 --> 00:09:43,200 Let me do it here. 170 00:09:43,200 --> 00:09:46,600 [no audio] 171 00:09:46,600 --> 00:09:49,200 So I am going to design simple arithmetic calculator with 172 00:09:49,200 --> 00:09:53,000 the help of only addition symbol for time being because you 173 00:09:53,000 --> 00:09:55,900 can perform any operation, for time being 174 00:09:55,900 --> 00:10:01,200 I am going to create only addition arithmetic calculator, 175 00:10:02,700 --> 00:10:03,800 okay, otherwise simply 176 00:10:05,100 --> 00:10:06,800 'addit_cal.py'. 177 00:10:06,800 --> 00:10:10,100 [no audio] 178 00:10:10,100 --> 00:10:11,100 Just observe here guys. 179 00:10:11,100 --> 00:10:14,900 What I am going to do is, suppose if I take 'a' equals to some 3, 180 00:10:14,900 --> 00:10:19,300 and 'b' equals to some 5, and I want to find the 'result', 'result=' 181 00:10:19,300 --> 00:10:23,200 nothing but 'a+b', and I can print, using 'f' string 182 00:10:23,200 --> 00:10:24,200 I can print 183 00:10:25,400 --> 00:10:43,800 "The addition of and =", or "is ". Right. See guys, if 184 00:10:43,800 --> 00:10:47,300 this is your Python Script or Python program in this you 185 00:10:47,300 --> 00:10:48,400 have four lines. 186 00:10:49,500 --> 00:10:54,000 See for any line if you observe there is no space at starting, 187 00:10:54,600 --> 00:10:57,500 that is the rule of your Python, that is the basic rule for your 188 00:10:57,500 --> 00:11:01,400 Python, don't provide a space before starting any line until 189 00:11:01,400 --> 00:11:05,100 and unless if there is any special requirement for that. As 190 00:11:05,100 --> 00:11:07,900 of now all are normal lines, straight forward, straight lines. 191 00:11:08,900 --> 00:11:12,500 Right. That's why I'm not giving any space before starting your 192 00:11:12,500 --> 00:11:13,400 any of the lines. 193 00:11:14,700 --> 00:11:19,100 Right. And whenever if you run, your Python will run your program 194 00:11:19,100 --> 00:11:20,700 from top to down line by line. 195 00:11:20,700 --> 00:11:23,500 [no audio] 196 00:11:23,500 --> 00:11:25,800 Then what is the very first line? 'a=3'. That means 197 00:11:25,800 --> 00:11:29,500 somewhere in memory 'a' value will be assigned as 3. Same 198 00:11:29,500 --> 00:11:33,300 way 'b', then 'result'. You know 'a + b', is the addition. So 199 00:11:33,300 --> 00:11:37,900 'a' value is 3 and 'b' value is 5. 3 + 5, 8, you are assigning to 200 00:11:37,900 --> 00:11:40,600 'result'. Then you are printing those values, right? 201 00:11:40,700 --> 00:11:41,900 That's what we are doing here. 202 00:11:43,200 --> 00:11:45,200 Now let me save it and run it. 203 00:11:45,200 --> 00:11:48,400 [no audio] 204 00:11:48,400 --> 00:11:52,300 So I am going to save it, and you know how to run your Python 205 00:11:52,300 --> 00:11:54,500 script or program from command line, 206 00:11:54,500 --> 00:11:59,100 simply your python interpreter space your program name. 207 00:11:59,500 --> 00:12:00,700 That's what I am doing here. 208 00:12:01,000 --> 00:12:03,200 See, "The addition of 3 and 5 is 8", you are getting. 209 00:12:03,700 --> 00:12:06,300 But if I run this program again, and again, I am going to 210 00:12:06,300 --> 00:12:10,200 get same result. If it is addition calculator it should not 211 00:12:10,400 --> 00:12:13,500 give the addition for fixed numbers. Whenever if you are running 212 00:12:13,500 --> 00:12:18,000 that script, that program it has to take two values minimum from the user. 213 00:12:18,900 --> 00:12:21,900 You know whenever if you want to provide input for your script, 214 00:12:22,200 --> 00:12:26,500 you have a command or statement called 'input' in your Python, 215 00:12:27,000 --> 00:12:28,400 in Python 3.x. 216 00:12:29,800 --> 00:12:31,200 Let me open our script. 217 00:12:31,200 --> 00:12:35,400 [no audio] 218 00:12:35,400 --> 00:12:38,800 See here, instead of fixing my values to 'a = 3', and 219 00:12:38,800 --> 00:12:39,900 'b = 5', 220 00:12:40,200 --> 00:12:43,500 what I am going to do is, let me comment these two lines. Now 221 00:12:43,900 --> 00:12:47,000 'a' value read from 'input'. 222 00:12:47,900 --> 00:12:51,400 So 'eval' is used to evaluate your given value. 223 00:12:52,100 --> 00:12:56,300 So "Enter first number". So this is just info you know already 224 00:12:56,400 --> 00:12:59,200 about your 'input'. Then same way 225 00:12:59,500 --> 00:13:03,300 I want to get 'b' value from 'input'. So 226 00:13:03,300 --> 00:13:06,800 'input(Enter second number")' 227 00:13:06,800 --> 00:13:10,200 [no audio] 228 00:13:10,200 --> 00:13:12,400 That's it. Right. Now 229 00:13:12,400 --> 00:13:16,500 let me save this and see your code once whatever you have. 230 00:13:17,600 --> 00:13:18,800 Right. So guys if you 231 00:13:18,800 --> 00:13:22,300 observe here, first two lines are commented, that means 232 00:13:22,300 --> 00:13:25,900 your Python won't consider those two lines as your Python 233 00:13:25,900 --> 00:13:26,900 program lines. 234 00:13:26,900 --> 00:13:28,800 [no audio] 235 00:13:28,800 --> 00:13:30,400 Now very first line is this one. 236 00:13:30,800 --> 00:13:33,400 So whenever if you run top to down, you know that, the very 237 00:13:33,400 --> 00:13:37,100 first line is 'a=2'. We know whenever there is an 238 00:13:37,100 --> 00:13:40,700 '=' symbol, that is an assignment operator. Whenever if you 239 00:13:40,700 --> 00:13:43,700 have an assignment operator, assignment operator will try 240 00:13:43,700 --> 00:13:46,900 to get first right side value, whatever you have. 241 00:13:48,400 --> 00:13:50,600 Now, in right side you have some syntax, 242 00:13:50,600 --> 00:13:53,100 this is helpful to read something from command line. 243 00:13:53,100 --> 00:13:55,800 So whatever I am going to provide on command line that will 244 00:13:55,800 --> 00:13:59,500 read by this expression and that value will be assigned to 245 00:13:59,500 --> 00:14:03,600 'a' by your '=' symbol, or with your assignment operator. Right. 246 00:14:04,000 --> 00:14:09,800 Let me run our code whatever we have. See that, "Enter the first 247 00:14:09,800 --> 00:14:13,200 number". I am entering number 6, suppose. Then immediately in 248 00:14:13,200 --> 00:14:17,100 the second line, right, you have once again "Enter second number". 249 00:14:17,200 --> 00:14:20,600 And so because of this "Enter first number", I am entering 250 00:14:20,600 --> 00:14:24,400 6, then I'm going to press 'Enter' on my keyboard so that 251 00:14:24,500 --> 00:14:28,600 this 6 will go and store into 'a' with the help of this expression, 252 00:14:29,200 --> 00:14:32,500 this syntax, right. Then immediately in the next line 253 00:14:32,500 --> 00:14:34,800 we have "Enter your second number". 254 00:14:34,900 --> 00:14:37,300 I am going to enter suppose something number called 9. 255 00:14:38,500 --> 00:14:43,300 That's it. You're getting 6, 9, "result is 15". Now, 256 00:14:43,300 --> 00:14:47,000 your program is like, you know simple addition calculator. 257 00:14:47,000 --> 00:14:48,900 [no audio] 258 00:14:48,900 --> 00:14:49,900 Right. 259 00:14:49,900 --> 00:14:52,500 [no audio] 260 00:14:52,500 --> 00:14:57,900 But after doing some advanced level concepts you can 261 00:14:57,900 --> 00:15:02,300 design a simple arithmetic calculator with your Python, that 262 00:15:02,300 --> 00:15:04,900 means addition, subtraction, multiplication, division, modulo, 263 00:15:04,900 --> 00:15:08,300 floor division, whatever the operator, whatever the operation 264 00:15:08,300 --> 00:15:10,100 you need all those operations 265 00:15:10,100 --> 00:15:13,600 you can do with the help of your Python scripting. So for 266 00:15:13,600 --> 00:15:16,300 that you need to include some logic, before including some 267 00:15:16,300 --> 00:15:20,100 logic you should know some concepts. We'll discuss that concepts 268 00:15:20,100 --> 00:15:23,800 first, and then we will once again design a full-fledged 269 00:15:23,800 --> 00:15:25,800 arithmetic calculator with help of 270 00:15:25,800 --> 00:15:30,000 your Python Scripting. Okay, for time being this is very simple 271 00:15:30,000 --> 00:15:34,500 one. Okay, so guys here we discussed about arithmetic operators 272 00:15:34,500 --> 00:15:39,100 and assignment operators, and also how to read any two numbers, 273 00:15:39,200 --> 00:15:41,800 and then how to find addition. The same way 274 00:15:41,800 --> 00:15:46,300 you can try for your addition, subtraction, multiplication, 275 00:15:46,300 --> 00:15:50,200 division, modulo, floor division, and exponential. You just try. 276 00:15:50,700 --> 00:15:53,200 Write a separate Python Script for each and every concept 277 00:15:53,200 --> 00:15:54,300 here whatever we have. 278 00:15:54,300 --> 00:15:56,500 [no audio] 279 00:15:56,500 --> 00:15:58,300 Right. Fine. 280 00:15:59,000 --> 00:16:01,100 Okay guys, thank you for watching this video. 281 00:16:01,100 --> 00:16:09,122 [no audio]