Data type conversion
Hello guys,
we will here talk about data type
conversion in python. We have almost entered in this world of python, and
we should know that it is very easy to shift your data from one form to another
of needed.
On simple
level, we will look how we can change the data type from int to string, into to
float and so on.
We have initiated
the variable with an integer and gave commands to print out it in float, string
and integer itself.
Let’s check out the output,
Another example,
Output
Now we will take a look how we will be changing list into tuple and set by using tuple() and set(). As set doesn’t contain any repeated items, so, repeated items will be discarded when changing a list to set.
Output
Conversion other than this like converting a list to dictionary, it’s a bit tricky. Click here, for more into this.
No comments:
Post a Comment