SiteMap  | About    

Python Type Conversion

Python has five standard Data Types : Numbers (integer, floating-point number), String, List, Tuple, Dictionary. They all have distinct representations and Python sets the variable type based on the value that is assigned to it.

If you are ever unsure of the type of the particular object, you can use the type() function:


Sometimes it is necessary to convert values from one type to another. An example would be the conversion of an integer value into a floating point value or its textual representation as a string, and vice versa. Python defines type conversion functions to directly convert one data type to another which is useful in day to day and competitive program development.

Type Conversion in Python


Converting number type (int, float) to string

To convert from a string to an int:

To convert from a string to a float:

To convert from an int to a float

To convert from a float to an int (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.