1 00:00:00,570 --> 00:00:03,700 Python videotape conventions and typecasting. 2 00:00:04,710 --> 00:00:11,390 So in this discussion here, is that perspective respective two different ways to do that type convergence. 3 00:00:11,730 --> 00:00:18,810 So the process of converting the value of one data type, let it be integer string float, etc. to of 4 00:00:18,810 --> 00:00:21,540 the database is called a type conversion. 5 00:00:21,930 --> 00:00:25,100 Python has two types of type conversion techniques. 6 00:00:25,260 --> 00:00:31,480 One is the implicit type, one conversion and another one is that explicit type conversion. 7 00:00:31,680 --> 00:00:34,380 So two types of conversions are possible in Python. 8 00:00:34,530 --> 00:00:38,970 That is the implicit type and the one is the explicit type conversion. 9 00:00:39,180 --> 00:00:44,580 I think to have a better idea, let us go for one demonstration where it will be discussing all this 10 00:00:44,910 --> 00:00:47,050 concept, writing the code in Python. 11 00:00:47,220 --> 00:00:48,710 So here is a demonstration for you. 12 00:00:49,740 --> 00:00:53,540 We are going for implicit and explicit type conversion. 13 00:00:54,210 --> 00:01:01,380 So we have defined NUM identical to 123 and num float that is a flaw is equal to one point two three. 14 00:01:01,770 --> 00:01:06,100 So here we are doing this addition in between the integer and the float variable. 15 00:01:06,750 --> 00:01:14,970 So what we the data type of this Namu, I'm printing the NUM in the type Namfrel type and then the new 16 00:01:14,970 --> 00:01:17,350 we are going to print and it's respective Prypiat. 17 00:01:17,380 --> 00:01:18,340 So here is outcome. 18 00:01:19,050 --> 00:01:26,550 So num int is of type integer num flow, the type of float and here we are having this nominal the respective 19 00:01:26,550 --> 00:01:32,390 value that is one to four point two three and the digit I knew will be float here. 20 00:01:32,400 --> 00:01:39,990 That means automatically this num a. has been converted to the float by the implicit type conversion 21 00:01:39,990 --> 00:01:40,900 in Python. 22 00:01:41,490 --> 00:01:42,780 So let us go for the next one. 23 00:01:43,350 --> 00:01:46,410 So here you are having this integer and next one is a string. 24 00:01:46,770 --> 00:01:48,900 So their respective types are getting printed. 25 00:01:48,900 --> 00:01:50,740 So respective types are getting printed. 26 00:01:51,360 --> 00:01:51,960 So now. 27 00:01:53,250 --> 00:02:00,390 If I make the respective addition, there is a name, Interplast, no Estienne, if I do this addition, 28 00:02:00,390 --> 00:02:04,030 then obviously the implicit LDAP conversion will not take place. 29 00:02:04,050 --> 00:02:08,430 That means if I go for the execution, that means adding one integer with the string. 30 00:02:09,360 --> 00:02:15,420 Then it will produce one error and the error is known as a type error, it has been raised and unsupported 31 00:02:15,420 --> 00:02:21,690 apparent types for blast, that is IMT and that is the iron and steel. 32 00:02:21,720 --> 00:02:26,300 So this is the unsupported types who are provided with the plant's operator. 33 00:02:26,610 --> 00:02:28,170 So that is the source of the error. 34 00:02:28,200 --> 00:02:30,380 So this line should not get executed. 35 00:02:30,390 --> 00:02:32,010 So I'm putting this one under command. 36 00:02:33,060 --> 00:02:38,670 But if I want to do here, this can find that integer and the string variables are defined, their respective 37 00:02:38,670 --> 00:02:40,200 types have got printed. 38 00:02:40,530 --> 00:02:46,500 And now I'm converting this NUM estimate to integer and ascending to the is back again. 39 00:02:47,380 --> 00:02:49,880 So now we can also change the variable name here. 40 00:02:49,900 --> 00:02:57,040 No issues, but here, just updating this name still with the integer converted value from the string 41 00:02:57,040 --> 00:03:01,780 to the individual, and that will be assigned to Mystere and the type of the name instead has got printed. 42 00:03:01,810 --> 00:03:06,730 So here we are expecting it to print up the type of string here to print of the type of integer. 43 00:03:07,420 --> 00:03:13,750 So now number some is called to name and last name, as they are now the name instead of the type of 44 00:03:13,750 --> 00:03:15,940 integer so that Edison can take. 45 00:03:16,150 --> 00:03:22,720 So Namsan will print assumption and type of some will be also the type of integer you can find this 46 00:03:22,720 --> 00:03:22,890 one. 47 00:03:23,500 --> 00:03:27,190 So Andy is a type of class A.. 48 00:03:27,190 --> 00:03:31,870 And now Mystere before the typecasting is Class Steyr. 49 00:03:32,260 --> 00:03:37,360 So name is dead after the typecasting class and after doing the typecasting. 50 00:03:37,750 --> 00:03:45,220 If you go on printing that type of mysterious printing that one as respective integer, and then after 51 00:03:45,220 --> 00:03:51,070 doing the addition between these two, that is some print and that will be the type of integer, because 52 00:03:51,520 --> 00:03:56,680 when you're printing that type of lump-sum, you are getting this one as Class A.. 53 00:03:57,190 --> 00:04:04,930 So in this way, you have discussed how to how to do the explicit type conversion and what is implicit 54 00:04:04,930 --> 00:04:07,090 type conversion in this particular example. 55 00:04:07,570 --> 00:04:08,830 Thanks for watching this video.