1 00:00:00,680 --> 00:00:03,840 By two numbers, we're having different type of numbers. 2 00:00:03,860 --> 00:00:09,490 We can present in Biton, we shall be discussing on that number data types. 3 00:00:09,500 --> 00:00:12,440 So Python supports three no data types. 4 00:00:12,590 --> 00:00:19,160 The first one is that in digits, there's integer numbers like one hundred two zero three zero, something 5 00:00:19,160 --> 00:00:22,060 like this as an example, floating by numbers. 6 00:00:22,310 --> 00:00:27,430 These are the examples are given and complex numbers are to be written in this particular format. 7 00:00:27,560 --> 00:00:36,080 So like your three plus fauji five plus, then in this way we can use a type function to know which 8 00:00:36,080 --> 00:00:42,980 class available are available, belongs to an instance function to check if it is belong to a certain 9 00:00:42,980 --> 00:00:44,220 particular class or not. 10 00:00:44,840 --> 00:00:46,250 So we are having two functions. 11 00:00:46,250 --> 00:00:51,200 One is a type which will tell the type of the function and another one is the instance which will tell 12 00:00:51,350 --> 00:00:54,530 whether this particular a variable is of the type or not. 13 00:00:55,640 --> 00:01:04,140 While individuals can be of any length if flooding the number is accurate, only up to 15 decimal places 14 00:01:04,370 --> 00:01:08,680 there is a 16 decimal place will be incorrect in that case. 15 00:01:09,020 --> 00:01:11,960 So that is the position we are having for the ultimate number. 16 00:01:12,110 --> 00:01:18,680 But in case of integers, while integers, it can be of any length numbers we deal with every day, 17 00:01:18,680 --> 00:01:22,060 a decimal that is the best in numbers system. 18 00:01:22,070 --> 00:01:27,350 Python can also express binary octal and hexadecimal numbers. 19 00:01:27,350 --> 00:01:33,680 Also as computer programmers, generally embedded programmers need to work with the binary. 20 00:01:34,040 --> 00:01:39,560 The binary number system is having the best two or the hexadecimal that is the best sixteen and octal 21 00:01:39,560 --> 00:01:43,010 that is a best eight number systems in Python. 22 00:01:43,010 --> 00:01:49,800 We can present these numbers by appropriately placing a prefix before that number. 23 00:01:50,030 --> 00:01:51,060 What are the prefix? 24 00:01:51,530 --> 00:01:58,910 So here you see we can write here as Gedo Small B or Gedo capital B as a binary number prefix. 25 00:01:59,150 --> 00:02:07,310 We are having this Gedo small or or zero capital law as Octonal number prefix with having zero small 26 00:02:07,310 --> 00:02:11,770 X or capital X as hexadecimal number prefix. 27 00:02:11,960 --> 00:02:15,500 So these are the prefix we are having to represent the respective number. 28 00:02:17,100 --> 00:02:22,000 No type conversion from one step to another type, we can do the conversions accordingly. 29 00:02:22,350 --> 00:02:28,440 We can also use the building functions like you're in deep, which will convert to their respective 30 00:02:28,510 --> 00:02:34,440 integer float and the complex functions to convert between types explicitly. 31 00:02:34,620 --> 00:02:41,440 These functions can even convert from string so it can take a string as input and convert it to integer. 32 00:02:41,700 --> 00:02:47,280 In this case, convert to float in this case and convert the current conflicts complex number in the 33 00:02:47,280 --> 00:02:49,090 using this particular complex function. 34 00:02:49,530 --> 00:02:55,200 So I think let us go for one demonstration where we'll be discussing how these numbers can be operated, 35 00:02:55,320 --> 00:03:03,240 can be handwrote, can be doing the typecasting in python coding numbers in Python can have mainly three 36 00:03:03,240 --> 00:03:04,250 different types. 37 00:03:04,980 --> 00:03:06,270 First one is the integer. 38 00:03:06,660 --> 00:03:09,380 So here you see the value, one is equal to 100. 39 00:03:09,390 --> 00:03:11,760 So this 100 is of type integer. 40 00:03:12,270 --> 00:03:18,000 And then we're having the next one as flawed in case of load value is 224. 41 00:03:18,030 --> 00:03:24,630 So it is the type float class and this particular float will always have some decimal point here and 42 00:03:24,630 --> 00:03:25,860 fractional part will be there. 43 00:03:26,400 --> 00:03:33,240 And then we're are having another type that is known as a complex and this complex type numbers will 44 00:03:33,240 --> 00:03:36,410 be expressed in the form of discipline plus six J. 45 00:03:36,720 --> 00:03:38,670 So it is one of the examples we have given. 46 00:03:39,210 --> 00:03:41,800 So we are having three different types added. 47 00:03:42,180 --> 00:03:48,900 One is the and next one is a float and the last one is a complex class in about python and integer and 48 00:03:48,900 --> 00:03:54,600 floating point numbers are separated by the presence of or absence of that decimal point. 49 00:03:54,930 --> 00:03:58,140 So in case of five foot eight, only five, it is an integer. 50 00:03:58,140 --> 00:04:01,540 But if you write the 5.0, it will be up the 29th floor. 51 00:04:02,280 --> 00:04:08,210 OK, so now here you see having this value on initialized with the value 100 and then we are going for 52 00:04:08,230 --> 00:04:09,910 the print type of value one. 53 00:04:10,290 --> 00:04:16,680 And also we are checking is instance, value and value, unflawed and value and complex. 54 00:04:17,040 --> 00:04:21,670 If I execute this particular part, we are getting this type as class type of A.. 55 00:04:22,080 --> 00:04:28,440 And this is in Stansel return, a boolean which will check that this value is of the type and they are 56 00:04:28,440 --> 00:04:28,770 not. 57 00:04:29,130 --> 00:04:30,260 And that is true here. 58 00:04:30,270 --> 00:04:33,690 But in case of load and complex, it is returning false. 59 00:04:34,170 --> 00:04:39,000 Similarly, you are doing the same type of testing here in case of how to do if a go on executing. 60 00:04:39,000 --> 00:04:42,990 We are getting the required output so value to a.. 61 00:04:43,230 --> 00:04:47,370 If we pass these two parameters to is instance, I'm getting the output false. 62 00:04:47,610 --> 00:04:53,880 But here in this case, as this is opti flawed, so is instant's value to camoflauge will return true 63 00:04:54,120 --> 00:04:56,870 and value to Kharma complex will return false. 64 00:04:57,570 --> 00:04:59,610 So now let us go for this complex. 65 00:05:00,810 --> 00:05:04,620 So here we are having value three is equal to 50 plus six G. 66 00:05:05,040 --> 00:05:08,130 So if we go on executing, we are getting the output like this. 67 00:05:08,130 --> 00:05:09,330 So it gets up. 68 00:05:09,340 --> 00:05:13,860 And because of flawed with the is instant's method, we are getting this false. 69 00:05:14,100 --> 00:05:19,060 But with the complex is instance value three comma complex, it is returning true here. 70 00:05:19,530 --> 00:05:25,200 So in this way we have tested that how that number, for instance, can be tested or the number type 71 00:05:25,200 --> 00:05:35,880 can be tested using the method is instance this python in Python also we can have other different corresponding 72 00:05:35,880 --> 00:05:37,340 representations of data. 73 00:05:37,560 --> 00:05:43,020 There is a binary which will have the best tool, Hexis hexadecimal, which will be having the best 74 00:05:43,020 --> 00:05:46,400 16 and octal which will be having the best eight here. 75 00:05:46,800 --> 00:05:52,680 So numbers we deal with everyday are having the best 10 that is of a decimal numbers. 76 00:05:52,860 --> 00:05:56,010 But other than this decimal, we can work with the best two. 77 00:05:56,020 --> 00:05:57,510 That is a binary number system. 78 00:05:57,510 --> 00:06:02,040 We are having this hexadecimal with the best 16 and octal with the best eight here. 79 00:06:02,430 --> 00:06:08,190 So to represent one binary number, we can easily write a zero B as a prefix to this number. 80 00:06:08,550 --> 00:06:10,650 You can write this being in the capital letter also. 81 00:06:10,860 --> 00:06:17,040 So if we go on printing this Jarobi one one zero one, that means this one one zero one is not in decimal, 82 00:06:17,040 --> 00:06:24,270 but in binary zero x instant for the hexadecimal and Gedo all will be standing for this octal here. 83 00:06:24,630 --> 00:06:27,030 So now let me let me go for the execution. 84 00:06:27,030 --> 00:06:33,210 You can find that if I execute this part, I'm getting thirteen because eight plus fold that estriol 85 00:06:33,210 --> 00:06:38,690 plus one that is thirteen here, because this particular place is having the principle of zero. 86 00:06:38,760 --> 00:06:44,510 That is one this particular place is having the one that is two of two. 87 00:06:44,520 --> 00:06:46,520 That is four and three. 88 00:06:46,530 --> 00:06:47,390 That is eight. 89 00:06:47,640 --> 00:06:51,020 So eight plus four plus one thirteen we are getting hit. 90 00:06:51,390 --> 00:06:59,070 So in case of this geto X, a, b so A's having the value in hexadecimal as ten so sixteen to the power 91 00:06:59,070 --> 00:07:00,300 of one into ten. 92 00:07:00,690 --> 00:07:05,840 We are getting here 160 and B's having eleven so eleven into sixteen. 93 00:07:06,780 --> 00:07:08,640 So you are landing with eleven only. 94 00:07:08,910 --> 00:07:12,960 So 160 plus we are getting the value 171. 95 00:07:13,530 --> 00:07:16,440 In the last case you can find that it is two into. 96 00:07:16,500 --> 00:07:24,250 It is one to one, because it is represented in the terms of octal so two into one plus three to zero. 97 00:07:24,540 --> 00:07:28,370 So we are getting these values six plus three and that is 19 here. 98 00:07:28,710 --> 00:07:32,790 So in place of writing this small bit, you can also go for the capital B.. 99 00:07:33,900 --> 00:07:38,740 This is I'm replacing this one as Capital X and replacing this one as capital. 100 00:07:39,210 --> 00:07:41,950 Then also we are going to get the same output here. 101 00:07:42,180 --> 00:07:48,510 Now, here you see here we are having this particular value, 10 in terms of integer and thirteen point 102 00:07:48,510 --> 00:07:50,910 four is nothing but a floor data. 103 00:07:51,150 --> 00:07:53,610 So what will happen if you go on printing this one? 104 00:07:53,880 --> 00:07:58,060 So you see the result is being converted to the respective float here. 105 00:07:58,410 --> 00:08:04,410 So operations like addition and subtraction, which will which will deal with just dealing with this 106 00:08:04,410 --> 00:08:10,260 integer and the float, and then automatically it will be converted to the float implicitly. 107 00:08:11,730 --> 00:08:16,350 So here you see we're having this endangered operand here, we're having this float operand, if any 108 00:08:16,350 --> 00:08:21,610 one of these float, then the result will be implicitly converted to the float type. 109 00:08:22,680 --> 00:08:25,080 So now we are going to have this type conversion. 110 00:08:25,410 --> 00:08:28,010 So ten point five is up that float. 111 00:08:28,350 --> 00:08:32,340 And if you want to convert it to integer, we can get output like this. 112 00:08:32,370 --> 00:08:34,960 So ten is getting output is producing. 113 00:08:35,460 --> 00:08:39,210 So now here we are having this minus twenty point ninety nine. 114 00:08:39,220 --> 00:08:41,070 So it is a float type. 115 00:08:41,070 --> 00:08:43,340 So we do the type constant integer. 116 00:08:43,500 --> 00:08:48,870 We are getting this one as minus 20 so we can find this one that when we are doing the conversion to 117 00:08:48,870 --> 00:08:52,570 integer, it is not changing the sign of the number. 118 00:08:52,920 --> 00:08:54,650 So here we are having this float then. 119 00:08:54,840 --> 00:08:59,880 So this then is ultra type integer because there is no fractional part, there is no decimal point. 120 00:09:00,150 --> 00:09:04,950 But as I data type conversion here, so the output has become ten point zero. 121 00:09:05,440 --> 00:09:07,110 Now consider this example. 122 00:09:07,560 --> 00:09:10,890 Data one is equal to zero point one plus zero point two. 123 00:09:11,220 --> 00:09:13,790 And you were just printing the value of data one. 124 00:09:14,280 --> 00:09:19,560 So if you execute this code, we are finding that we are expecting we were expecting the value should 125 00:09:19,560 --> 00:09:24,240 be printed at zero point three because zero point one plus zero point two should be open three. 126 00:09:24,630 --> 00:09:30,090 But you are finding that, but having so many different zeros after that and then 140 is coming. 127 00:09:30,240 --> 00:09:36,240 So it is an error is getting cost due to the hardware of our system, not due to the PyCon. 128 00:09:36,930 --> 00:09:44,640 So if we want to check whether zero plus one plus zero plus one plus zero point two is GEAPPEN three 129 00:09:44,640 --> 00:09:50,880 or not, then in that case will be finding that the coalition is giving the output asphalt's to overcome 130 00:09:50,880 --> 00:09:51,660 this issue. 131 00:09:51,690 --> 00:09:58,380 You can use that decimal model that comes with Biton, and while floating print numbers have the precision 132 00:09:58,380 --> 00:10:04,950 of two decimal places and the decimal model has users citable position accordingly. 133 00:10:05,400 --> 00:10:10,860 So here you see where having this data one is equal to zero point one plus zero point to print data 134 00:10:10,860 --> 00:10:11,150 one. 135 00:10:11,520 --> 00:10:16,110 So we are getting this output as zero point three and multiple number of zeros and four. 136 00:10:16,440 --> 00:10:21,960 And then heroes who we are just doing one calculation that is zero point one point to zero into two 137 00:10:21,960 --> 00:10:22,860 point five zero. 138 00:10:22,980 --> 00:10:24,480 And we are printing the value of data. 139 00:10:24,480 --> 00:10:26,430 One, we are getting this 3.0 as well. 140 00:10:26,910 --> 00:10:33,930 So now from decimal import decimal as a D. So if we now do the calculation in this way, you can see 141 00:10:34,170 --> 00:10:38,150 the rate in this particular code and we are going to print the respective result. 142 00:10:38,370 --> 00:10:42,450 We are getting the value as zero point three, which which was expected. 143 00:10:42,600 --> 00:10:46,550 And for this outcome, we are getting this output as three point zero zero. 144 00:10:46,860 --> 00:10:55,350 So in this way, the problem which you are facing in case of Biton can be overcome using the from decimal 145 00:10:55,350 --> 00:10:57,180 import decimal here. 146 00:10:57,180 --> 00:10:59,450 This decimal will be in the uppercase. 147 00:11:00,720 --> 00:11:04,350 So here we are using one elĂ­as that is as digit. 148 00:11:04,710 --> 00:11:06,570 Now we shall discuss fractions. 149 00:11:06,930 --> 00:11:14,460 Biton provides operations involving fractional numbers through its fractions model and this fraction 150 00:11:14,460 --> 00:11:21,930 model will help us to convert one floating by number to a new monetary denominator from where both the 151 00:11:21,930 --> 00:11:25,200 numerator and the denominator will be of the type integer. 152 00:11:25,710 --> 00:11:30,960 Actually, fraction has enumerated any denominator, and both of which are integers. 153 00:11:31,110 --> 00:11:35,410 And this model has supples for rational number arithmetic. 154 00:11:35,700 --> 00:11:37,610 So let us go for this example here. 155 00:11:37,950 --> 00:11:44,910 So you see that from fractions import fraction as F and this is the respective model we are executing 156 00:11:44,910 --> 00:11:45,110 here. 157 00:11:45,480 --> 00:11:52,290 So you can find that one point five can be expressed in terms of three by two and this three is nothing 158 00:11:52,290 --> 00:11:58,550 but one integer numerator and two is nothing but an integer which is being which has been placed as 159 00:11:58,560 --> 00:11:59,300 a denominator. 160 00:11:59,760 --> 00:12:04,470 So print F five which will give you the five and print F one come off. 161 00:12:04,470 --> 00:12:07,330 I will give you the value that is one by five. 162 00:12:07,710 --> 00:12:12,620 So while creating fraction from float, we might get some unusual results. 163 00:12:12,630 --> 00:12:19,170 And this is due to the imperfect binary floating by no representation and fortunately a fraction allows 164 00:12:19,170 --> 00:12:21,770 us to instantiate with the string as well. 165 00:12:22,140 --> 00:12:26,530 And this is preferred option when using the decimal numbers. 166 00:12:26,880 --> 00:12:29,460 Now we shall discuss that math model. 167 00:12:29,760 --> 00:12:36,480 Biton offers model like math and the random to carry out different mathematics, like your trigonometry, 168 00:12:36,720 --> 00:12:40,470 logarithms, probability statistics and etc.. 169 00:12:40,770 --> 00:12:45,330 So just consider this set up called So Bitan Math Model. 170 00:12:45,350 --> 00:12:50,940 So we have imported the math and then we have we used multiple different functions available in the 171 00:12:50,940 --> 00:12:51,510 math here. 172 00:12:51,690 --> 00:12:58,020 So PI calls log log ap'tin XP factorial and signage. 173 00:12:58,230 --> 00:13:00,640 So here is the respective outputs we are getting here. 174 00:13:01,110 --> 00:13:09,770 So if we want to print, if we want to print the absolute opposite, minus twelve point two for if want 175 00:13:09,780 --> 00:13:10,560 to bring this one. 176 00:13:10,810 --> 00:13:17,740 Then in that case, we need not to use that math model here so we can use that as a best minus twelve 177 00:13:17,740 --> 00:13:18,280 point four. 178 00:13:18,310 --> 00:13:23,320 You can find that we consider only the magnitude part and assigned part has been ignored. 179 00:13:23,710 --> 00:13:24,880 Now, let us come to this. 180 00:13:25,030 --> 00:13:26,370 That is a random here. 181 00:13:26,710 --> 00:13:32,820 So here to see we are going for the random, random random range that is Hypercom 15. 182 00:13:33,010 --> 00:13:35,920 So the initial value is a start value, which is optional. 183 00:13:35,920 --> 00:13:40,140 If you don't provide any initial value, the value will become considered as zero. 184 00:13:40,420 --> 00:13:42,450 And the last one, the next one value. 185 00:13:42,460 --> 00:13:43,540 That is a second argument. 186 00:13:43,540 --> 00:13:45,190 Well, passing is mandatory. 187 00:13:45,190 --> 00:13:48,500 That is the dominating value of the stock value and that is exclusive. 188 00:13:48,790 --> 00:13:54,430 That means if the random numbers will be generated, including five to 15, exclusive. 189 00:13:54,760 --> 00:13:59,990 So in this way, you can go on printing and we can generate multiple random numbers added. 190 00:14:00,400 --> 00:14:02,050 So the first value is optional. 191 00:14:02,140 --> 00:14:03,840 That is, there is a start value. 192 00:14:04,090 --> 00:14:05,910 The second value is mandatory. 193 00:14:05,920 --> 00:14:06,820 That is a stop value. 194 00:14:06,970 --> 00:14:10,940 Then you can also put another argument, comma, after put in there. 195 00:14:11,120 --> 00:14:12,770 That is that is a step below. 196 00:14:13,210 --> 00:14:18,460 So here we have printed random range in between five to 10, four times. 197 00:14:18,490 --> 00:14:22,630 So now we are having this 11, eight, 14 and 13. 198 00:14:22,630 --> 00:14:26,170 If we execute the code once again, we are getting a different set of values. 199 00:14:26,350 --> 00:14:29,250 If we execute the code once again, we are getting a different set of values. 200 00:14:29,650 --> 00:14:33,830 So now we are having one list here, then random choice day. 201 00:14:34,030 --> 00:14:35,910 So there is nothing but a list here. 202 00:14:36,010 --> 00:14:39,220 See, it has picked up the random choices to you. 203 00:14:39,490 --> 00:14:44,340 If you go for execution once again, we are getting this value, as do you hear it once again. 204 00:14:44,530 --> 00:14:45,760 So if you go for it again. 205 00:14:46,920 --> 00:14:51,050 You can find that we're getting here on here, so now this is a print day. 206 00:14:51,310 --> 00:14:57,960 Now we are going for Random Day and then if we print that, we can find that this is the respective 207 00:14:57,960 --> 00:15:00,180 different arrangement of this list. 208 00:15:00,180 --> 00:15:02,300 Elements, at least elements have suffered. 209 00:15:02,670 --> 00:15:08,100 And then we are having this print random elements in front of the random element that the method is 210 00:15:08,100 --> 00:15:11,530 random so he can bring their respective random element here. 211 00:15:11,880 --> 00:15:18,690 So in this way, in this particular program, we have discussed multiple different aspects of number 212 00:15:18,840 --> 00:15:20,330 type in our python. 213 00:15:20,670 --> 00:15:22,320 So let us go for a quick revision. 214 00:15:22,590 --> 00:15:29,130 So type is actually returning the type of the available is instances actually checking whether this 215 00:15:29,130 --> 00:15:31,440 particular variable is having this type or not. 216 00:15:31,590 --> 00:15:35,320 So that's why this instance is actually returning or false. 217 00:15:35,670 --> 00:15:39,790 So we have tested that one on integer, that one on float. 218 00:15:39,930 --> 00:15:42,100 We have destroyed that one on complex numbers. 219 00:15:42,480 --> 00:15:46,420 So here we have we had explicit numbers in terms of binary. 220 00:15:46,440 --> 00:15:51,510 So the prefix will be geto B, B can be a small letter or capital letter for the hexadecimal. 221 00:15:51,510 --> 00:15:52,650 The prefix should be zero. 222 00:15:52,650 --> 00:15:56,340 Execs can be lowercase or in the uppercase and for the octal. 223 00:15:56,340 --> 00:16:02,200 We are having this value which will be having the prefixes Gedo or we can be in the lowercase or uppercase. 224 00:16:02,690 --> 00:16:08,280 So here you can find that whenever we are doing some calculations involving integers and float, the 225 00:16:08,280 --> 00:16:11,030 result will get implicitly converted to the float. 226 00:16:11,490 --> 00:16:16,800 But having to describe conversion from this float to the integer, from this float to the integer, 227 00:16:16,890 --> 00:16:23,040 from this integer to the respective outputs that we have discussed this decimal here, how we can deal 228 00:16:23,040 --> 00:16:23,490 with that. 229 00:16:23,490 --> 00:16:28,640 We can have the control over the positions and then we are having this back on fractions. 230 00:16:28,650 --> 00:16:34,610 You can see that how the factions are working and then the math module and also the random model here. 231 00:16:34,920 --> 00:16:39,970 I think now you are getting this idea that how this numbers are getting handled in Python programming. 232 00:16:40,470 --> 00:16:41,670 Thanks for watching this video.