Python Conversion Between Data Types

We can convert between different data types by using different type conversion functions like int(), float(), str() etc. >>>float(10)

#Conversion to and from string must contain compatible values.
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '5p'

#We can even convert one sequence to another.
{10, 20, 30}
(40, 50, 60)
['S', 'I', 'L', 'A', 'N']

#To convert to dictionary, each element must be a pair
{10: 20, 30: 40}
{10: 20, 30: 40}

About the Author

Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc