1
00:00:00,000 --> 00:00:00,000
Hello guys.

2
00:00:00,000 --> 00:00:03,000
So we are going to continue the discussion with respect to Python.

3
00:00:03,000 --> 00:00:05,000
And in this video we are going to discuss about variables.

4
00:00:05,000 --> 00:00:06,000
Okay.

5
00:00:06,000 --> 00:00:07,000
Now what exactly is variables.

6
00:00:07,000 --> 00:00:10,000
And uh here I have also given the entire video outline.

7
00:00:10,000 --> 00:00:15,000
So we will first of all introduce like uh the topic is introduction to variables.

8
00:00:15,000 --> 00:00:18,000
Then we'll be seeing how we can declare and assign variables.

9
00:00:18,000 --> 00:00:20,000
Then we'll talk about the naming convention.

10
00:00:20,000 --> 00:00:21,000
Then we'll understand variable type.

11
00:00:21,000 --> 00:00:24,000
We'll see type checking and conversion dynamic typing.

12
00:00:24,000 --> 00:00:28,000
And finally we'll be seeing a lot of practical examples and common errors okay.

13
00:00:28,000 --> 00:00:31,000
So all these things will be specifically covered in this video okay.

14
00:00:31,000 --> 00:00:34,000
Now first of all, as usual let's go with the definition.

15
00:00:34,000 --> 00:00:39,000
So variables are fundamental elements in programming used to store data that can be referenced and manipulated

16
00:00:39,000 --> 00:00:41,000
in a program in Python.

17
00:00:41,000 --> 00:00:46,000
Variables are created when you assign a value to them, and they do not need explicit declaration to

18
00:00:46,000 --> 00:00:48,000
reserve memory space.

19
00:00:48,000 --> 00:00:52,000
The declaration happens automatically when you assign a value to a variable.

20
00:00:52,000 --> 00:00:52,000
Okay.

21
00:00:52,000 --> 00:00:57,000
So, uh, the best way to give you an example is that let's say if I define a is equal to 100.

22
00:00:57,000 --> 00:00:59,000
So this basically becomes the variable.

23
00:00:59,000 --> 00:01:04,000
And always remember guys, whenever you start a new notebook file always make sure to select the kernel

24
00:01:04,000 --> 00:01:04,000
okay.

25
00:01:04,000 --> 00:01:06,000
Now if I'm going to write a is equal to 100.

26
00:01:06,000 --> 00:01:11,000
This basically means that I've created a variable a and I've assigned a value to 100 okay.

27
00:01:11,000 --> 00:01:16,000
Now uh, obviously in my previous video I've also defined some basic variables and all and I've assigned

28
00:01:16,000 --> 00:01:21,000
some values, let's say string, numerical, uh, integers, floating point, anything, any values

29
00:01:21,000 --> 00:01:22,000
you can basically assign.

30
00:01:23,000 --> 00:01:24,000
Uh, we'll be learning more about it.

31
00:01:24,000 --> 00:01:34,000
Uh, so first of all, let's go ahead and understanding about declaring, declaring and assigning variables.

32
00:01:34,000 --> 00:01:34,000
Okay.

33
00:01:35,000 --> 00:01:40,000
So here, uh, you'll be able to see that, uh, let's say I'm going to define age is equal to 32.

34
00:01:40,000 --> 00:01:45,000
I'm going to probably define height is equal to six feet or 6.1.

35
00:01:45,000 --> 00:01:47,000
That is specifically my height.

36
00:01:47,000 --> 00:01:48,000
So I'm writing it down.

37
00:01:48,000 --> 00:01:49,000
Height is equal to 6.1.

38
00:01:49,000 --> 00:01:52,000
Then let's say name is equal to my name.

39
00:01:52,000 --> 00:01:53,000
I will go ahead and define crush.

40
00:01:54,000 --> 00:01:58,000
Uh, and then here you can also see that I can also define a boolean variable.

41
00:01:58,000 --> 00:02:02,000
Let's say I will go ahead and define is underscore student okay.

42
00:02:02,000 --> 00:02:04,000
I will also talk about naming convention.

43
00:02:04,000 --> 00:02:07,000
Uh what is the best naming convention of defining a variable.

44
00:02:07,000 --> 00:02:08,000
What are the good practices.

45
00:02:08,000 --> 00:02:09,000
Everything I'll be discussing about.

46
00:02:09,000 --> 00:02:12,000
So let's say I'm going to define a boolean variable as true right.

47
00:02:12,000 --> 00:02:15,000
We'll learn more about the specific data types in my next video.

48
00:02:15,000 --> 00:02:17,000
But here I'm just giving you an example okay.

49
00:02:17,000 --> 00:02:19,000
So h is equal to 32.

50
00:02:19,000 --> 00:02:19,000
This this is there.

51
00:02:19,000 --> 00:02:21,000
And I have actually written it right now.

52
00:02:21,000 --> 00:02:23,000
Let me quickly go ahead and print it.

53
00:02:23,000 --> 00:02:26,000
And this is how we assign a variable right.

54
00:02:26,000 --> 00:02:28,000
We are declaring a variable and we signing some values.

55
00:02:28,000 --> 00:02:29,000
Right.

56
00:02:29,000 --> 00:02:34,000
So now let me just go ahead and print printing the variables.

57
00:02:34,000 --> 00:02:34,000
Right.

58
00:02:34,000 --> 00:02:36,000
So here you can see.

59
00:02:36,000 --> 00:02:39,000
So now first of all I'm going to print age right.

60
00:02:39,000 --> 00:02:45,000
And this is where I will also show you how you can use uh different print, how you can uh, display

61
00:02:45,000 --> 00:02:46,000
in your console in a different way.

62
00:02:46,000 --> 00:02:48,000
So first of all, let's say I want to print age.

63
00:02:48,000 --> 00:02:53,000
So age colon let's say I want to assign this age colon with some value over here.

64
00:02:53,000 --> 00:02:55,000
So I will go ahead and define my variable h right.

65
00:02:55,000 --> 00:03:01,000
Similarly, if I go ahead and show you the next print statement here, I'm going to basically write

66
00:03:01,000 --> 00:03:02,000
height okay.

67
00:03:02,000 --> 00:03:06,000
And with respect to this particular height I am going to define another variable.

68
00:03:06,000 --> 00:03:08,000
Let's say this will basically be my height.

69
00:03:08,000 --> 00:03:12,000
Another next thing that I'm going to print over here is my name.

70
00:03:12,000 --> 00:03:17,000
And here you can probably see that I'm going to basically define my name.

71
00:03:17,000 --> 00:03:19,000
And let me just go ahead and write comma.

72
00:03:19,000 --> 00:03:20,000
And this will basically be my name.

73
00:03:20,000 --> 00:03:21,000
Right.

74
00:03:21,000 --> 00:03:25,000
So if I want to define all these things you here, you can see I'm displaying age is equal to 32.

75
00:03:25,000 --> 00:03:26,000
Height is equal to 6.1.

76
00:03:26,000 --> 00:03:28,000
Name is equal to crush.

77
00:03:28,000 --> 00:03:32,000
That basically means see, when I'm printing I can also call this particular variable that I have actually

78
00:03:32,000 --> 00:03:32,000
defined.

79
00:03:32,000 --> 00:03:33,000
Okay.

80
00:03:33,000 --> 00:03:35,000
So these are some of the ways.

81
00:03:35,000 --> 00:03:40,000
Again we will be discussing about more different boolean type more different data types as we go ahead.

82
00:03:40,000 --> 00:03:43,000
And that is how we declare different different variables.

83
00:03:43,000 --> 00:03:46,000
But just a basic idea for you with respect to the variable declaration.

84
00:03:47,000 --> 00:03:47,000
Okay.

85
00:03:47,000 --> 00:03:51,000
Now coming to the next one, which is basically called as naming convention.

86
00:03:51,000 --> 00:03:52,000
And this is the most important one.

87
00:03:52,000 --> 00:03:55,000
Like how should we name a variable.

88
00:03:55,000 --> 00:03:55,000
Right.

89
00:03:56,000 --> 00:03:58,000
Then for this you really need to know about the naming convention.

90
00:03:59,000 --> 00:04:05,000
Some of the important points that I would like to mention over here, let's say uh, variables, uh,

91
00:04:05,000 --> 00:04:06,000
name.

92
00:04:06,000 --> 00:04:06,000
Right.

93
00:04:06,000 --> 00:04:14,000
The variable name that we define right should be should be descriptive.

94
00:04:15,000 --> 00:04:15,000
Okay.

95
00:04:15,000 --> 00:04:16,000
Then.

96
00:04:16,000 --> 00:04:24,000
Uh, the second point that I would like to mention, they must always start with a letter.

97
00:04:24,000 --> 00:04:24,000
Okay.

98
00:04:24,000 --> 00:04:26,000
So this is the second condition.

99
00:04:26,000 --> 00:04:29,000
Or it can also start with an underscore.

100
00:04:29,000 --> 00:04:29,000
Okay.

101
00:04:29,000 --> 00:04:33,000
Underscore like underscore uh this kind of underscore mark.

102
00:04:33,000 --> 00:04:33,000
Right.

103
00:04:33,000 --> 00:04:42,000
And uh it can contain letters numbers and underscore in between.

104
00:04:42,000 --> 00:04:43,000
Right.

105
00:04:43,000 --> 00:04:44,000
In between.

106
00:04:44,000 --> 00:04:49,000
But always understand they must always start with a letter or underscore.

107
00:04:49,000 --> 00:04:52,000
And it can contain letters, numbers and underscores.

108
00:04:52,000 --> 00:04:52,000
Okay.

109
00:04:52,000 --> 00:04:54,000
Within inside that okay.

110
00:04:55,000 --> 00:04:57,000
And uh, one more thing.

111
00:04:57,000 --> 00:04:59,000
Very important point, which I've already mentioned.

112
00:04:59,000 --> 00:05:04,000
Variables names are case sensitive.

113
00:05:05,000 --> 00:05:05,000
Okay.

114
00:05:05,000 --> 00:05:06,000
This also I have defined it.

115
00:05:06,000 --> 00:05:11,000
So these are some of the naming important naming convention with respect to the variables okay.

116
00:05:11,000 --> 00:05:13,000
Now let's see some kind of example over here.

117
00:05:13,000 --> 00:05:17,000
So first of all I will just go ahead and write some valid variable name.

118
00:05:17,000 --> 00:05:17,000
Okay.

119
00:05:17,000 --> 00:05:20,000
So valid variable names.

120
00:05:20,000 --> 00:05:26,000
So first valid variable name I'm going to define it as first underscore name is equal to crush okay.

121
00:05:26,000 --> 00:05:30,000
Uh last underscore name is equal to Nick.

122
00:05:30,000 --> 00:05:30,000
Right.

123
00:05:30,000 --> 00:05:34,000
So is this a good way of writing a variable.

124
00:05:34,000 --> 00:05:34,000
Yes.

125
00:05:34,000 --> 00:05:35,000
Does it start with a letter.

126
00:05:35,000 --> 00:05:36,000
Yes.

127
00:05:36,000 --> 00:05:37,000
It starts with a letter.

128
00:05:37,000 --> 00:05:41,000
Does can it contain letter number or numbers or underscores?

129
00:05:41,000 --> 00:05:42,000
Yes, it can contain.

130
00:05:42,000 --> 00:05:45,000
So here you can see I am having letters or underscore.

131
00:05:45,000 --> 00:05:49,000
I can also put numbers in between but not in the starting right.

132
00:05:49,000 --> 00:05:51,000
So this is a good way of defining a variable.

133
00:05:51,000 --> 00:05:52,000
Okay.

134
00:05:52,000 --> 00:05:55,000
So here uh this absolutely works fine.

135
00:05:55,000 --> 00:06:02,000
Let me say show you some invalid variable name invalid variable names okay.

136
00:06:02,000 --> 00:06:05,000
So let's say that I define with a number.

137
00:06:05,000 --> 00:06:05,000
Right.

138
00:06:05,000 --> 00:06:08,000
And if I go ahead and define over here age is equal to 30.

139
00:06:08,000 --> 00:06:11,000
See I'm getting an error saying that invalid decimal literal right.

140
00:06:11,000 --> 00:06:13,000
So I cannot start with a letter.

141
00:06:13,000 --> 00:06:14,000
So this is one way okay.

142
00:06:15,000 --> 00:06:20,000
The another way is that, uh can I define something like this first dash name.

143
00:06:20,000 --> 00:06:21,000
Right.

144
00:06:21,000 --> 00:06:22,000
Can I define like this.

145
00:06:22,000 --> 00:06:24,000
First dash name is equal to, let's say Krish.

146
00:06:25,000 --> 00:06:26,000
Can I define like this?

147
00:06:26,000 --> 00:06:27,000
Will I get an error.

148
00:06:27,000 --> 00:06:30,000
So here you can see cannot assign to expression here.

149
00:06:30,000 --> 00:06:34,000
Maybe you mean double equal to or instead of equal to.

150
00:06:34,000 --> 00:06:36,000
So this is not being considered.

151
00:06:36,000 --> 00:06:38,000
This symbol is also not being used.

152
00:06:38,000 --> 00:06:38,000
Right.

153
00:06:39,000 --> 00:06:43,000
Uh so obviously this is also an invalid variable name.

154
00:06:43,000 --> 00:06:43,000
Right.

155
00:06:43,000 --> 00:06:48,000
The third invalid variable name can I use at the rate and define a name variable.

156
00:06:48,000 --> 00:06:49,000
Right.

157
00:06:49,000 --> 00:06:51,000
So let me just go ahead and check it out.

158
00:06:51,000 --> 00:06:54,000
So here I'll go ahead and write Chris will I get an error.

159
00:06:54,000 --> 00:06:55,000
It says invalid syntax.

160
00:06:55,000 --> 00:06:57,000
Maybe you meant so and so right.

161
00:06:57,000 --> 00:07:00,000
So this is also not a valid variable name.

162
00:07:00,000 --> 00:07:03,000
It is an invalid variable name okay.

163
00:07:03,000 --> 00:07:06,000
And already I have spoken about case sensitive.

164
00:07:06,000 --> 00:07:07,000
Right.

165
00:07:07,000 --> 00:07:08,000
Case sensitivity.

166
00:07:08,000 --> 00:07:09,000
Right.

167
00:07:09,000 --> 00:07:12,000
If I define name is equal to Chris.

168
00:07:13,000 --> 00:07:17,000
And let's say I have defined capital name is equal to Naic.

169
00:07:17,000 --> 00:07:18,000
Right.

170
00:07:18,000 --> 00:07:20,000
Both this are different, right?

171
00:07:20,000 --> 00:07:21,000
It is not same.

172
00:07:21,000 --> 00:07:22,000
Right.

173
00:07:22,000 --> 00:07:27,000
If I really want to compare, can I compare like this num name double equal to capital name.

174
00:07:27,000 --> 00:07:29,000
It'll be giving false right?

175
00:07:29,000 --> 00:07:29,000
Yes.

176
00:07:29,000 --> 00:07:30,000
The values.

177
00:07:30,000 --> 00:07:31,000
If it is same it will give me true.

178
00:07:31,000 --> 00:07:35,000
But in short you can see that these are different identifiers, right?

179
00:07:35,000 --> 00:07:38,000
Later on I can do the comparison operation and I can do it right.

180
00:07:38,000 --> 00:07:40,000
So obviously case sensitivity is also there.

181
00:07:40,000 --> 00:07:41,000
Right.

182
00:07:41,000 --> 00:07:45,000
So this was related to something related to the naming conventions okay.

183
00:07:45,000 --> 00:07:51,000
Now let me just go ahead and make you understand about some of the variable types okay.

184
00:07:51,000 --> 00:07:55,000
So uh we will continue the writing the code here itself.

185
00:07:55,000 --> 00:08:02,000
So let me just go ahead and write understanding variable types okay.

186
00:08:02,000 --> 00:08:08,000
Now one thing you need to understand Python is dynamically typed.

187
00:08:08,000 --> 00:08:08,000
Okay.

188
00:08:08,000 --> 00:08:11,000
Dynamically typed.

189
00:08:12,000 --> 00:08:13,000
What does this mean?

190
00:08:13,000 --> 00:08:16,000
This means the type of a variable.

191
00:08:17,000 --> 00:08:22,000
Type of a variable is determined at runtime.

192
00:08:23,000 --> 00:08:25,000
Determined at runtime right.

193
00:08:25,000 --> 00:08:27,000
So this is very much important okay.

194
00:08:27,000 --> 00:08:32,000
And some of the important data types are like int float string and boolean.

195
00:08:32,000 --> 00:08:32,000
Right.

196
00:08:32,000 --> 00:08:35,000
So let's say if I write age equal to 25 right.

197
00:08:36,000 --> 00:08:40,000
So when I execute it during the runtime it will understand.

198
00:08:40,000 --> 00:08:40,000
Hey fine.

199
00:08:40,000 --> 00:08:42,000
Integer is basically getting assigned.

200
00:08:42,000 --> 00:08:44,000
So age is an integer variable right.

201
00:08:44,000 --> 00:08:48,000
And let's say that I will go ahead and define some more variables.

202
00:08:48,000 --> 00:08:48,000
Right.

203
00:08:48,000 --> 00:08:50,000
Let's say height right.

204
00:08:50,000 --> 00:08:52,000
I'm going to basically go ahead and define height.

205
00:08:52,000 --> 00:08:54,000
Let's say I'm going to write 6.1.

206
00:08:54,000 --> 00:08:57,000
So this this is nothing but it is integer.

207
00:08:57,000 --> 00:08:59,000
This is nothing but this is float.

208
00:08:59,000 --> 00:09:02,000
See how I'm also using the single line comments.

209
00:09:02,000 --> 00:09:02,000
Right.

210
00:09:02,000 --> 00:09:05,000
Let's say if I'm going to define my name.

211
00:09:05,000 --> 00:09:06,000
So this will basically be Chris.

212
00:09:06,000 --> 00:09:10,000
So this is what this is nothing but str the string.

213
00:09:10,000 --> 00:09:12,000
And finally if I go ahead and define is underscore student.

214
00:09:12,000 --> 00:09:15,000
This is basically my boolean variable right.

215
00:09:15,000 --> 00:09:16,000
So boolean.

216
00:09:16,000 --> 00:09:18,000
Uh sorry I will assign it as true.

217
00:09:18,000 --> 00:09:20,000
So this basically becomes my boolean variable.

218
00:09:20,000 --> 00:09:26,000
Now if I go ahead and print the type of any of this right like age.

219
00:09:26,000 --> 00:09:28,000
So I'm going to basically get integer.

220
00:09:28,000 --> 00:09:29,000
The class will be integer.

221
00:09:29,000 --> 00:09:29,000
During the runtime.

222
00:09:29,000 --> 00:09:30,000
It is able to understand it.

223
00:09:30,000 --> 00:09:35,000
If I go ahead and print what is the type of name I'm actually going to get string right.

224
00:09:35,000 --> 00:09:40,000
So similarly you will be able to find out different different types like what classes it basically belongs

225
00:09:40,000 --> 00:09:44,000
to Okay, now one more thing.

226
00:09:44,000 --> 00:09:50,000
Right here I will discuss about one very important point and understand one thing guys.

227
00:09:50,000 --> 00:09:51,000
Here I'll be showing some example.

228
00:09:51,000 --> 00:09:57,000
But when I go ahead with more session, more different lessons as we go ahead, right.

229
00:09:57,000 --> 00:09:59,000
I'll be reusing all this things.

230
00:09:59,000 --> 00:10:04,000
Don't think that I'm just going to write for a single time over here, because this all things will

231
00:10:04,000 --> 00:10:05,000
again get repeated.

232
00:10:05,000 --> 00:10:05,000
Okay.

233
00:10:05,000 --> 00:10:07,000
With all the different, different examples.

234
00:10:07,000 --> 00:10:12,000
Now let me just go ahead and make you understand about type checking and conversion okay.

235
00:10:12,000 --> 00:10:14,000
Now type checking and conversion.

236
00:10:14,000 --> 00:10:15,000
What does this basically mean.

237
00:10:15,000 --> 00:10:16,000
Obviously type checking.

238
00:10:16,000 --> 00:10:17,000
You have known right.

239
00:10:17,000 --> 00:10:19,000
So if I go ahead and write type off height.

240
00:10:19,000 --> 00:10:24,000
So that basically means I'm going to get the uh data type of this height variable.

241
00:10:24,000 --> 00:10:24,000
Right.

242
00:10:24,000 --> 00:10:28,000
So in short I'm actually getting float over here right now.

243
00:10:28,000 --> 00:10:29,000
My question rises.

244
00:10:29,000 --> 00:10:32,000
Can we convert one data type to the other data type?

245
00:10:32,000 --> 00:10:33,000
Is it possible?

246
00:10:33,000 --> 00:10:34,000
So let me just go and show you.

247
00:10:34,000 --> 00:10:38,000
Let's say if I go ahead and write age is equal to 25 right now.

248
00:10:38,000 --> 00:10:44,000
You know that if I go ahead and write print type of age, so what I'm actually going to get it is an

249
00:10:44,000 --> 00:10:45,000
integer, right?

250
00:10:45,000 --> 00:10:48,000
But now I am going to perform some type conversion.

251
00:10:48,000 --> 00:10:53,000
Type conversion basically means I am going to convert this integer value into a string value.

252
00:10:53,000 --> 00:10:59,000
Let's say So if I go ahead and write h underscore str, and if I go and use this str function, write

253
00:10:59,000 --> 00:11:01,000
str function is what string right.

254
00:11:01,000 --> 00:11:03,000
This is what is the class that I'm actually getting.

255
00:11:03,000 --> 00:11:07,000
Now if I want to convert this age into string I can use this str.

256
00:11:07,000 --> 00:11:09,000
And I can use this age variable over here.

257
00:11:09,000 --> 00:11:16,000
Right now if I go ahead and write print h print age underscore str okay.

258
00:11:16,000 --> 00:11:22,000
And after that I will just go ahead and write print type of age underscore HDR.

259
00:11:22,000 --> 00:11:22,000
Right.

260
00:11:22,000 --> 00:11:29,000
So if I go ahead and execute it see initially it was int later on uh when I printed this age underscore

261
00:11:29,000 --> 00:11:32,000
HDR here you can probably see that I'm getting 25 okay.

262
00:11:32,000 --> 00:11:35,000
But the type of this particular value is string.

263
00:11:35,000 --> 00:11:37,000
Right here you can see string.

264
00:11:37,000 --> 00:11:41,000
So this this value from integer it has got converted into strings okay.

265
00:11:41,000 --> 00:11:43,000
Now the question rises.

266
00:11:43,000 --> 00:11:44,000
Krish.

267
00:11:44,000 --> 00:11:46,000
Uh, what are different types of type conversion.

268
00:11:46,000 --> 00:11:47,000
Can I do okay?

269
00:11:47,000 --> 00:11:49,000
Can can I do something like this.

270
00:11:49,000 --> 00:11:50,000
Can I write.

271
00:11:50,000 --> 00:11:52,000
Age is equal to in string like 25.

272
00:11:52,000 --> 00:11:54,000
And can I convert this into int.

273
00:11:55,000 --> 00:11:56,000
Let's see.

274
00:11:56,000 --> 00:11:56,000
Right.

275
00:11:56,000 --> 00:11:57,000
Let's see this.

276
00:11:57,000 --> 00:11:59,000
So the answer is yes.

277
00:11:59,000 --> 00:12:00,000
You are able to convert it right.

278
00:12:00,000 --> 00:12:07,000
So if I go ahead and print uh the type of int of age, yes, definitely you are able to convert it.

279
00:12:07,000 --> 00:12:08,000
Right.

280
00:12:08,000 --> 00:12:10,000
And here I'm just going to close it.

281
00:12:10,000 --> 00:12:11,000
Yes the class is int.

282
00:12:11,000 --> 00:12:16,000
This is fine but still I will just go ahead and use one more.

283
00:12:16,000 --> 00:12:17,000
Some more examples.

284
00:12:17,000 --> 00:12:26,000
Let's say if I go ahead and write my name is Krish right now do I can I convert this into an integer?

285
00:12:26,000 --> 00:12:28,000
The answer is no, right?

286
00:12:28,000 --> 00:12:31,000
Because obviously Krish is a complete sentence, right?

287
00:12:31,000 --> 00:12:36,000
If I talk about 25 in string manner, this is basically a numerical value itself, right?

288
00:12:36,000 --> 00:12:40,000
So even though it is in a string, I can convert this into an int type.

289
00:12:40,000 --> 00:12:43,000
But over here this is my string complete string.

290
00:12:43,000 --> 00:12:45,000
I cannot just convert this into an integer type or a float type.

291
00:12:45,000 --> 00:12:50,000
So here you basically get an error saying that invalid literal for int with base ten Krish.

292
00:12:50,000 --> 00:12:51,000
Right?

293
00:12:51,000 --> 00:12:54,000
So this is the value that you are able to get it over here right.

294
00:12:54,000 --> 00:12:56,000
Another example some more example.

295
00:12:56,000 --> 00:12:57,000
Let's define some float value.

296
00:12:57,000 --> 00:12:58,000
Right.

297
00:12:58,000 --> 00:13:04,000
So let's say my uh my height is nothing but 6.1 okay.

298
00:13:04,000 --> 00:13:09,000
Or let's say 6.0 or 6.0 or 5.11 okay.

299
00:13:09,000 --> 00:13:10,000
Something.

300
00:13:10,000 --> 00:13:10,000
Okay.

301
00:13:11,000 --> 00:13:19,000
Now if I go ahead and see the type of height, what exactly it is, It is nothing but float, right?

302
00:13:19,000 --> 00:13:22,000
Can I convert this float into an integer?

303
00:13:23,000 --> 00:13:24,000
The answer is yes.

304
00:13:24,000 --> 00:13:29,000
So if I go ahead and write int and I do the typecasting for this particular height variable, you'll

305
00:13:29,000 --> 00:13:31,000
be able to see that I'm able to get five right.

306
00:13:31,000 --> 00:13:33,000
That basically means it is just going to remove the decimal.

307
00:13:33,000 --> 00:13:34,000
Right.

308
00:13:34,000 --> 00:13:35,000
Can I do the opposite again?

309
00:13:35,000 --> 00:13:39,000
Can I again typecast this from int to float again?

310
00:13:39,000 --> 00:13:43,000
Yes I can, and it is going to give me 5.0 right.

311
00:13:43,000 --> 00:13:44,000
So 5.11.

312
00:13:44,000 --> 00:13:47,000
Initially I converted this into an integer I got 5.0.

313
00:13:47,000 --> 00:13:49,000
Then again sorry I got five.

314
00:13:49,000 --> 00:13:51,000
And then again I converted that into float.

315
00:13:51,000 --> 00:13:52,000
So I got 5.0.

316
00:13:52,000 --> 00:13:57,000
So this is some example with respect to the conversion right type checking conversion.

317
00:13:57,000 --> 00:14:01,000
So this is what I really want to show you over here okay.

318
00:14:01,000 --> 00:14:03,000
Now let me do one thing.

319
00:14:04,000 --> 00:14:09,000
Let me talk about one very important concept, which is called as dynamic typing.

320
00:14:09,000 --> 00:14:10,000
Okay.

321
00:14:10,000 --> 00:14:13,000
And this is probably the most amazing feature in Python.

322
00:14:13,000 --> 00:14:13,000
Okay.

323
00:14:13,000 --> 00:14:19,000
Let's say I'm going to define a variable ten okay I'm going to define a variable ten okay.

324
00:14:19,000 --> 00:14:23,000
Now let me just go ahead and write print var.

325
00:14:25,000 --> 00:14:30,000
Where I'm going to print this var and I'm going to also print type of where.

326
00:14:30,000 --> 00:14:31,000
Okay.

327
00:14:31,000 --> 00:14:32,000
Type of where.

328
00:14:33,000 --> 00:14:33,000
Perfect.

329
00:14:33,000 --> 00:14:35,000
So this initially is an integer.

330
00:14:35,000 --> 00:14:37,000
Then obviously it should give ten.

331
00:14:37,000 --> 00:14:38,000
It should display ten.

332
00:14:38,000 --> 00:14:40,000
And it should say that hey it is an integer.

333
00:14:40,000 --> 00:14:48,000
Now Python allows the type of a variable to change as the program executes.

334
00:14:48,000 --> 00:14:48,000
Right?

335
00:14:48,000 --> 00:14:50,000
So let me write down this particular comment.

336
00:14:50,000 --> 00:14:58,000
Python allows the type of a variable to change.

337
00:14:59,000 --> 00:15:04,000
To change as the program executes.

338
00:15:04,000 --> 00:15:04,000
Right.

339
00:15:04,000 --> 00:15:05,000
Amazing, right.

340
00:15:06,000 --> 00:15:07,000
Now, what does this basically mean?

341
00:15:07,000 --> 00:15:11,000
Now I can go ahead and change the value of var and I can write.

342
00:15:11,000 --> 00:15:11,000
Hello.

343
00:15:11,000 --> 00:15:12,000
Okay.

344
00:15:12,000 --> 00:15:16,000
And let's say I'm going to print var comma type of var.

345
00:15:17,000 --> 00:15:17,000
Okay.

346
00:15:17,000 --> 00:15:20,000
This time obviously you know what it will output will be string.

347
00:15:21,000 --> 00:15:23,000
If you're not satisfied with this again you can change.

348
00:15:23,000 --> 00:15:27,000
So as you keep on executing the code you can keep on changing it.

349
00:15:27,000 --> 00:15:30,000
Let's say now this time I defined it as a float variable.

350
00:15:30,000 --> 00:15:36,000
Now if I go ahead and write print var okay var comma type of var.

351
00:15:36,000 --> 00:15:41,000
So if I go ahead and execute this here, you'll be able to see that I'm able to get this right.

352
00:15:41,000 --> 00:15:45,000
So see initially it was ten class int hello class str.

353
00:15:45,000 --> 00:15:47,000
And finally 3.14 class is float.

354
00:15:47,000 --> 00:15:49,000
So what is basically happening.

355
00:15:49,000 --> 00:15:54,000
Python is allowing this type of a variable to change as the program gets executed.

356
00:15:54,000 --> 00:15:54,000
Right.

357
00:15:54,000 --> 00:15:56,000
So we can basically do this.

358
00:15:56,000 --> 00:15:56,000
Okay.

359
00:15:56,000 --> 00:16:00,000
Now uh, let's do one amazing thing.

360
00:16:00,000 --> 00:16:06,000
Let's just create a simple, uh, application with whatever things we are specifically not.

361
00:16:06,000 --> 00:16:06,000
Okay.

362
00:16:07,000 --> 00:16:09,000
And before that, let me just talk about input.

363
00:16:09,000 --> 00:16:10,000
Okay.

364
00:16:10,000 --> 00:16:11,000
Now, what exactly is input?

365
00:16:11,000 --> 00:16:15,000
Let's say that, uh, a user wants to give some values, right?

366
00:16:15,000 --> 00:16:16,000
Let's say age.

367
00:16:16,000 --> 00:16:19,000
And I've told that hey, user, you give the value.

368
00:16:19,000 --> 00:16:21,000
What is the age?

369
00:16:21,000 --> 00:16:21,000
Okay.

370
00:16:22,000 --> 00:16:23,000
What is the age.

371
00:16:23,000 --> 00:16:24,000
So I, I am a user.

372
00:16:24,000 --> 00:16:26,000
I want to probably give the value over here.

373
00:16:26,000 --> 00:16:34,000
So if I use this right input function and if I print h over here, see what will happen.

374
00:16:34,000 --> 00:16:37,000
So once I execute this statement now see what will happen.

375
00:16:37,000 --> 00:16:40,000
So here you can see uh an input box has got opened.

376
00:16:40,000 --> 00:16:43,000
So here I'm just going to give my uh, age.

377
00:16:43,000 --> 00:16:45,000
Let's say the age is 23 okay.

378
00:16:45,000 --> 00:16:47,000
And I'm going to press enter.

379
00:16:47,000 --> 00:16:49,000
So here you can see I'm printing the age now.

380
00:16:49,000 --> 00:16:51,000
One very important thing to show you right.

381
00:16:51,000 --> 00:16:54,000
What will be the type of this age.

382
00:16:54,000 --> 00:16:54,000
Okay.

383
00:16:54,000 --> 00:16:59,000
So that basically means whenever I'm giving any input from this particular input box by using this input

384
00:16:59,000 --> 00:17:02,000
function, what will be the type of it by default type.

385
00:17:02,000 --> 00:17:04,000
So here I'm going to go ahead and write 23.

386
00:17:04,000 --> 00:17:06,000
And here you can see it is a string type.

387
00:17:06,000 --> 00:17:09,000
So let's say I want to probably get this particular input.

388
00:17:09,000 --> 00:17:12,000
And then also convert this into an integer or float.

389
00:17:12,000 --> 00:17:15,000
So I can again typecast this entire thing.

390
00:17:15,000 --> 00:17:15,000
Right.

391
00:17:15,000 --> 00:17:21,000
So now if I go ahead and execute this now, let me just go ahead and write 23 and press enter.

392
00:17:21,000 --> 00:17:22,000
So here you can see I'm getting a class hint.

393
00:17:22,000 --> 00:17:23,000
Right.

394
00:17:23,000 --> 00:17:30,000
So this is uh, one very important functionality for uh, uh, the entire, uh, input function over

395
00:17:30,000 --> 00:17:30,000
here.

396
00:17:30,000 --> 00:17:34,000
And uh, this can be very handy and can be used in various places.

397
00:17:34,000 --> 00:17:35,000
Okay.

398
00:17:35,000 --> 00:17:39,000
So, uh, I hope you are able to execute this and, uh, you are able to understand this.

399
00:17:39,000 --> 00:17:41,000
So I'm just going to show you one example again.

400
00:17:41,000 --> 00:17:43,000
Now let us do one thing.

401
00:17:43,000 --> 00:17:47,000
Let us simply create one simple calculator okay.

402
00:17:47,000 --> 00:17:50,000
Now this simple calculator will be amazing.

403
00:17:50,000 --> 00:17:55,000
So here you can just see that what this calculator is doing I'm giving two numbers.

404
00:17:55,000 --> 00:17:58,000
Uh again I'm using this input uh, number one.

405
00:17:58,000 --> 00:17:58,000
Again.

406
00:17:58,000 --> 00:18:00,000
Number two, then some.

407
00:18:00,000 --> 00:18:04,000
I'm doing num plus num one plus num two difference num one minus num two.

408
00:18:04,000 --> 00:18:08,000
And product is num one multiplied by num two num one divided by num two.

409
00:18:08,000 --> 00:18:11,000
We'll discuss more about this operators as we go ahead.

410
00:18:11,000 --> 00:18:14,000
And we are just going to display all the sum difference and all.

411
00:18:14,000 --> 00:18:15,000
So let's go execute it.

412
00:18:15,000 --> 00:18:17,000
Let's say the first number is 56.

413
00:18:17,000 --> 00:18:20,000
I'll go ahead and press enter again I've got my another cell.

414
00:18:20,000 --> 00:18:26,000
Let's say I'm going to write 43 or 10 something and press enter.

415
00:18:26,000 --> 00:18:31,000
So here you can see I'm able to see all the answers like some difference product and quotient.

416
00:18:31,000 --> 00:18:32,000
Right.

417
00:18:32,000 --> 00:18:35,000
So yes, uh, this was uh, amazing.

418
00:18:35,000 --> 00:18:40,000
This was I guess, you, you are able to understand many things about variables.

419
00:18:40,000 --> 00:18:42,000
Uh, this was it for my side.

420
00:18:42,000 --> 00:18:46,000
Uh, in the next video, I am going to probably discuss more about data types.

421
00:18:46,000 --> 00:18:49,000
And then finally we'll also be discussing about operators.

422
00:18:49,000 --> 00:18:50,000
What are the different different data types.

423
00:18:50,000 --> 00:18:52,000
Also we need to discuss about.

424
00:18:52,000 --> 00:18:53,000
So yes this was it for my side.

425
00:18:53,000 --> 00:18:54,000
I will see you in the next video.

426
00:18:54,000 --> 00:18:54,000
Thank you.

