# introduction

• as programmers, we are most likely aware that the programming is about getting/fetching data, manipulating it, and finally returning the format, which would like to be acquired. working with various and multiple data types might get us frustrated due to the Error examples, which are shown below

• type conversions help to resolve these kind of issues very easily, about which this article is about

• p.s the input() function in python gets all the input does not matter what in string format. so, if you are looking to get integer, float, or other type of data from the user, you might be required to manipulate it by one of the according type conversions

# errors

• as logical as it is, doing any mathematical operation on different kind of data types does not really make sense. by using type conversions it is easy to solve these, let’s show a couple of more example before moving to the usage part of them
• type() is a special python built-in function, which helps you to identifythe type of t a declared variable and to which class it actually belongs to
• the same case for all of them, let’s see how to resolve it

# usage

### int()

• p.s type conversion functions are supposed to be assigned to the value after usage, else, they do not replace the value of the assigned variable instantly, a.k.a inplace=False
• the function that converts the string type of integers to the integer type of integers. frustrated? no worries, check the examples below
• as was shown above, you can directly change the value of declared string as simple as that. however, how far can int() help you?

### str()

• what was done in the int() section, where a str type of data was converted to int, the exact same operation can be done vice versa.
• as was noticed above, int type of data can not have a len a.k.a length, however, str type of data can. so, we can just convert the int to string and find the length

### float()

• nothing different than the 2 mentioned and described above, besides, as the name suggests, float() converts the values into a float type of data :)
• yes! you can also convert integers to float values, not just the strings!

### complex()

• you probably have never seen this function before as long as you have messed with complex values in python
• feel free to learn about complex numbers by clicking here
• if you are not knew to the topic of complex numbers or have read the wikipedia article above, then the mathematical operations should completely make sense. but can we also use complex() for the conversions? :))
• simple as that! as long as your variable does not have any imaginary part, complex() is going to assign it as 0 by default

# interesting stuff

• is 3.0 equal to 3 that to 3+0j? :))
• yes, if you are converting the same integer to other types, they all are going to be the same in value for python :)