By two numbers, we're having different type of numbers.
We can present in Biton, we shall be discussing on that number data types.
So Python supports three no data types.
The first one is that in digits, there's integer numbers like one hundred two zero three zero, something
like this as an example, floating by numbers.
These are the examples are given and complex numbers are to be written in this particular format.
So like your three plus fauji five plus, then in this way we can use a type function to know which
class available are available, belongs to an instance function to check if it is belong to a certain
particular class or not.
So we are having two functions.
One is a type which will tell the type of the function and another one is the instance which will tell
whether this particular a variable is of the type or not.
While individuals can be of any length if flooding the number is accurate, only up to 15 decimal places
there is a 16 decimal place will be incorrect in that case.
So that is the position we are having for the ultimate number.
But in case of integers, while integers, it can be of any length numbers we deal with every day,
a decimal that is the best in numbers system.
Python can also express binary octal and hexadecimal numbers.
Also as computer programmers, generally embedded programmers need to work with the binary.
The binary number system is having the best two or the hexadecimal that is the best sixteen and octal
that is a best eight number systems in Python.
We can present these numbers by appropriately placing a prefix before that number.
What are the prefix?
So here you see we can write here as Gedo Small B or Gedo capital B as a binary number prefix.
We are having this Gedo small or or zero capital law as Octonal number prefix with having zero small
X or capital X as hexadecimal number prefix.
So these are the prefix we are having to represent the respective number.
No type conversion from one step to another type, we can do the conversions accordingly.
We can also use the building functions like you're in deep, which will convert to their respective
integer float and the complex functions to convert between types explicitly.
These functions can even convert from string so it can take a string as input and convert it to integer.
In this case, convert to float in this case and convert the current conflicts complex number in the
using this particular complex function.
So I think let us go for one demonstration where we'll be discussing how these numbers can be operated,
can be handwrote, can be doing the typecasting in python coding numbers in Python can have mainly three
different types.
First one is the integer.
So here you see the value, one is equal to 100.
So this 100 is of type integer.
And then we're having the next one as flawed in case of load value is 224.
So it is the type float class and this particular float will always have some decimal point here and
fractional part will be there.
And then we're are having another type that is known as a complex and this complex type numbers will
be expressed in the form of discipline plus six J.
So it is one of the examples we have given.
So we are having three different types added.
One is the and next one is a float and the last one is a complex class in about python and integer and
floating point numbers are separated by the presence of or absence of that decimal point.
So in case of five foot eight, only five, it is an integer.
But if you write the 5.0, it will be up the 29th floor.
OK, so now here you see having this value on initialized with the value 100 and then we are going for
the print type of value one.
And also we are checking is instance, value and value, unflawed and value and complex.
If I execute this particular part, we are getting this type as class type of A..
And this is in Stansel return, a boolean which will check that this value is of the type and they are
not.
And that is true here.
But in case of load and complex, it is returning false.
Similarly, you are doing the same type of testing here in case of how to do if a go on executing.
We are getting the required output so value to a..
If we pass these two parameters to is instance, I'm getting the output false.
But here in this case, as this is opti flawed, so is instant's value to camoflauge will return true
and value to Kharma complex will return false.
So now let us go for this complex.
So here we are having value three is equal to 50 plus six G.
So if we go on executing, we are getting the output like this.
So it gets up.
And because of flawed with the is instant's method, we are getting this false.
But with the complex is instance value three comma complex, it is returning true here.
So in this way we have tested that how that number, for instance, can be tested or the number type
can be tested using the method is instance this python in Python also we can have other different corresponding
representations of data.
There is a binary which will have the best tool, Hexis hexadecimal, which will be having the best
16 and octal which will be having the best eight here.
So numbers we deal with everyday are having the best 10 that is of a decimal numbers.
But other than this decimal, we can work with the best two.
That is a binary number system.
We are having this hexadecimal with the best 16 and octal with the best eight here.
So to represent one binary number, we can easily write a zero B as a prefix to this number.
You can write this being in the capital letter also.
So if we go on printing this Jarobi one one zero one, that means this one one zero one is not in decimal,
but in binary zero x instant for the hexadecimal and Gedo all will be standing for this octal here.
So now let me let me go for the execution.
You can find that if I execute this part, I'm getting thirteen because eight plus fold that estriol
plus one that is thirteen here, because this particular place is having the principle of zero.
That is one this particular place is having the one that is two of two.
That is four and three.
That is eight.
So eight plus four plus one thirteen we are getting hit.
So in case of this geto X, a, b so A's having the value in hexadecimal as ten so sixteen to the power
of one into ten.
We are getting here 160 and B's having eleven so eleven into sixteen.
So you are landing with eleven only.
So 160 plus we are getting the value 171.
In the last case you can find that it is two into.
It is one to one, because it is represented in the terms of octal so two into one plus three to zero.
So we are getting these values six plus three and that is 19 here.
So in place of writing this small bit, you can also go for the capital B..
This is I'm replacing this one as Capital X and replacing this one as capital.
Then also we are going to get the same output here.
Now, here you see here we are having this particular value, 10 in terms of integer and thirteen point
four is nothing but a floor data.
So what will happen if you go on printing this one?
So you see the result is being converted to the respective float here.
So operations like addition and subtraction, which will which will deal with just dealing with this
integer and the float, and then automatically it will be converted to the float implicitly.
So here you see we're having this endangered operand here, we're having this float operand, if any
one of these float, then the result will be implicitly converted to the float type.
So now we are going to have this type conversion.
So ten point five is up that float.
And if you want to convert it to integer, we can get output like this.
So ten is getting output is producing.
So now here we are having this minus twenty point ninety nine.
So it is a float type.
So we do the type constant integer.
We are getting this one as minus 20 so we can find this one that when we are doing the conversion to
integer, it is not changing the sign of the number.
So here we are having this float then.
So this then is ultra type integer because there is no fractional part, there is no decimal point.
But as I data type conversion here, so the output has become ten point zero.
Now consider this example.
Data one is equal to zero point one plus zero point two.
And you were just printing the value of data one.
So if you execute this code, we are finding that we are expecting we were expecting the value should
be printed at zero point three because zero point one plus zero point two should be open three.
But you are finding that, but having so many different zeros after that and then 140 is coming.
So it is an error is getting cost due to the hardware of our system, not due to the PyCon.
So if we want to check whether zero plus one plus zero plus one plus zero point two is GEAPPEN three
or not, then in that case will be finding that the coalition is giving the output asphalt's to overcome
this issue.
You can use that decimal model that comes with Biton, and while floating print numbers have the precision
of two decimal places and the decimal model has users citable position accordingly.
So here you see where having this data one is equal to zero point one plus zero point to print data
one.
So we are getting this output as zero point three and multiple number of zeros and four.
And then heroes who we are just doing one calculation that is zero point one point to zero into two
point five zero.
And we are printing the value of data.
One, we are getting this 3.0 as well.
So now from decimal import decimal as a D. So if we now do the calculation in this way, you can see
the rate in this particular code and we are going to print the respective result.
We are getting the value as zero point three, which which was expected.
And for this outcome, we are getting this output as three point zero zero.
So in this way, the problem which you are facing in case of Biton can be overcome using the from decimal
import decimal here.
This decimal will be in the uppercase.
So here we are using one elías that is as digit.
Now we shall discuss fractions.
Biton provides operations involving fractional numbers through its fractions model and this fraction
model will help us to convert one floating by number to a new monetary denominator from where both the
numerator and the denominator will be of the type integer.
Actually, fraction has enumerated any denominator, and both of which are integers.
And this model has supples for rational number arithmetic.
So let us go for this example here.
So you see that from fractions import fraction as F and this is the respective model we are executing
here.
So you can find that one point five can be expressed in terms of three by two and this three is nothing
but one integer numerator and two is nothing but an integer which is being which has been placed as
a denominator.
So print F five which will give you the five and print F one come off.
I will give you the value that is one by five.
So while creating fraction from float, we might get some unusual results.
And this is due to the imperfect binary floating by no representation and fortunately a fraction allows
us to instantiate with the string as well.
And this is preferred option when using the decimal numbers.
Now we shall discuss that math model.
Biton offers model like math and the random to carry out different mathematics, like your trigonometry,
logarithms, probability statistics and etc..
So just consider this set up called So Bitan Math Model.
So we have imported the math and then we have we used multiple different functions available in the
math here.
So PI calls log log ap'tin XP factorial and signage.
So here is the respective outputs we are getting here.
So if we want to print, if we want to print the absolute opposite, minus twelve point two for if want
to bring this one.
Then in that case, we need not to use that math model here so we can use that as a best minus twelve
point four.
You can find that we consider only the magnitude part and assigned part has been ignored.
Now, let us come to this.
That is a random here.
So here to see we are going for the random, random random range that is Hypercom 15.
So the initial value is a start value, which is optional.
If you don't provide any initial value, the value will become considered as zero.
And the last one, the next one value.
That is a second argument.
Well, passing is mandatory.
That is the dominating value of the stock value and that is exclusive.
That means if the random numbers will be generated, including five to 15, exclusive.
So in this way, you can go on printing and we can generate multiple random numbers added.
So the first value is optional.
That is, there is a start value.
The second value is mandatory.
That is a stop value.
Then you can also put another argument, comma, after put in there.
That is that is a step below.
So here we have printed random range in between five to 10, four times.
So now we are having this 11, eight, 14 and 13.
If we execute the code once again, we are getting a different set of values.
So now we are having one list here, then random choice day.
So there is nothing but a list here.
See, it has picked up the random choices to you.
If you go for execution once again, we are getting this value, as do you hear it once again.
So if you go for it again.
You can find that we're getting here on here, so now this is a print day.
Now we are going for Random Day and then if we print that, we can find that this is the respective
different arrangement of this list.
Elements, at least elements have suffered.
And then we are having this print random elements in front of the random element that the method is
random so he can bring their respective random element here.
So in this way, in this particular program, we have discussed multiple different aspects of number
type in our python.
So let us go for a quick revision.
So type is actually returning the type of the available is instances actually checking whether this
particular variable is having this type or not.
So that's why this instance is actually returning or false.
So we have tested that one on integer, that one on float.
We have destroyed that one on complex numbers.
So here we have we had explicit numbers in terms of binary.
So the prefix will be geto B, B can be a small letter or capital letter for the hexadecimal.
The prefix should be zero.
Execs can be lowercase or in the uppercase and for the octal.
We are having this value which will be having the prefixes Gedo or we can be in the lowercase or uppercase.
So here you can find that whenever we are doing some calculations involving integers and float, the
result will get implicitly converted to the float.
But having to describe conversion from this float to the integer, from this float to the integer,
from this integer to the respective outputs that we have discussed this decimal here, how we can deal
with that.
We can have the control over the positions and then we are having this back on fractions.
You can see that how the factions are working and then the math module and also the random model here.
I think now you are getting this idea that how this numbers are getting handled in Python programming.
Thanks for watching this video.