Python videotape conventions and typecasting.
So in this discussion here, is that perspective respective two different ways to do that type convergence.
So the process of converting the value of one data type, let it be integer string float, etc. to of
the database is called a type conversion.
Python has two types of type conversion techniques.
One is the implicit type, one conversion and another one is that explicit type conversion.
So two types of conversions are possible in Python.
That is the implicit type and the one is the explicit type conversion.
I think to have a better idea, let us go for one demonstration where it will be discussing all this
concept, writing the code in Python.
So here is a demonstration for you.
We are going for implicit and explicit type conversion.
So we have defined NUM identical to 123 and num float that is a flaw is equal to one point two three.
So here we are doing this addition in between the integer and the float variable.
So what we the data type of this Namu, I'm printing the NUM in the type Namfrel type and then the new
we are going to print and it's respective Prypiat.
So here is outcome.
So num int is of type integer num flow, the type of float and here we are having this nominal the respective
value that is one to four point two three and the digit I knew will be float here.
That means automatically this num a. has been converted to the float by the implicit type conversion
in Python.
So let us go for the next one.
So here you are having this integer and next one is a string.
So their respective types are getting printed.
So respective types are getting printed.
So now.
If I make the respective addition, there is a name, Interplast, no Estienne, if I do this addition,
then obviously the implicit LDAP conversion will not take place.
That means if I go for the execution, that means adding one integer with the string.
Then it will produce one error and the error is known as a type error, it has been raised and unsupported
apparent types for blast, that is IMT and that is the iron and steel.
So this is the unsupported types who are provided with the plant's operator.
So that is the source of the error.
So this line should not get executed.
So I'm putting this one under command.
But if I want to do here, this can find that integer and the string variables are defined, their respective
types have got printed.
And now I'm converting this NUM estimate to integer and ascending to the is back again.
So now we can also change the variable name here.
No issues, but here, just updating this name still with the integer converted value from the string
to the individual, and that will be assigned to Mystere and the type of the name instead has got printed.
So here we are expecting it to print up the type of string here to print of the type of integer.
So now number some is called to name and last name, as they are now the name instead of the type of
integer so that Edison can take.
So Namsan will print assumption and type of some will be also the type of integer you can find this
one.
So Andy is a type of class A..
And now Mystere before the typecasting is Class Steyr.
So name is dead after the typecasting class and after doing the typecasting.
If you go on printing that type of mysterious printing that one as respective integer, and then after
doing the addition between these two, that is some print and that will be the type of integer, because
when you're printing that type of lump-sum, you are getting this one as Class A..
So in this way, you have discussed how to how to do the explicit type conversion and what is implicit
type conversion in this particular example.
Thanks for watching this video.