Type casting in python by R4R Team

What is type casting -

Conversion of one data type to another type is called type casting that means in programming at runtime we change the type of the data or variable which store data.

Possible Type casting -
int to float
float to int
int to string
numeric string to int
list to string
list to set
set to list, etc.

program -

a=3.12
print(a) print(int(a))
# int to float
a=3
b=float(a)
print(b)

#string to int a='2'
print(int(a))

#list to set
l=[1,2,1,2]
print(set(l))


output -

3.12
3
3.0
2
{1, 2}


In this program, we done different type of type conversion.
Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!