In some situations, you will need to modify the data type of a variable.
So for example, you want to change an integer to a float,
or an integer to a boolean, a string to a float, etc.
And we have actually a good example here to work on.
The input function, as you saw before, always returns a string.
Okay, even if you give a number.
So then if you need to work with the number you got from the input,
you're going to have a problem because, well, this
number will actually be a string, not a number.
So you need to change the type for the variable, and this is called cast.
Okay, you are going to cast the type.
And to cast a variable, it's very easy.
Okay, so let's see with an example.
Let's say you want to cast a string, okay, two.
So we have the string here, a is a string.
So if I do type a, I have a string.
I want to cast a to an integer.
In this case, I simply do int a, okay.
You simply use the final data type you want, and then in parentheses,
you put the variable or the value you have now.
Okay, if I do int a, you can see now I have 67 without the quotes.
And if I do type int a, now this is of class int.
So this way you can change a value here from
whatever data type it is to the data type int.
You can also do the reverse if you want.
You can cast something into a string.
Let's say I want to cast 34.
This is going to give the string 34.
You can cast int to float, for example, float from three.
It's going to give 3.0.
You can do the opposite.
Int, let's say 3.0, is going to give three.
And let's see, for example, 3.7.
What do we have here?
We have just three, okay.
This is important when you cast a float number to an
integer number, the number is going to be truncated.
Okay, so whatever is after the comma is going to be lost.
Okay, so that's important to know.
And then, so we can also cast a boolean to an integer.
Let's see that.
Int true is going to give one.
And int false is going to give zero.
Okay, so actually, if you want to see a boolean with numbers,
well, when you have zero, it's going to be false.
Okay, if you have one, it's going to be true.
But in fact, if you have any other number, it's going to be true.
If you want to do, let's say, bool from 34, it's going to be true.
bool from minus one is going to be true.
The only value which is going to give false is zero.
All right, and with that, you can cast any type to any other type.