Python Module 6 Type Conversion
Python Module 6 Type Conversion
Type
Conversion in
Python
Type Conversion
wHat is type
conversion?
()
The process of converting the value of one data type
(integer, string, float, etc.) to another data type is called
** type conversion.
Implicit Explicit
Conversion Conversion
Arithmetic Casting
Operation Operation
Explicit Type Conversion or Type-
Casting
What is Type-
Casting?
()
In Explicit Conversion, users convert the data type of
an object to required data type. We use the predefined
** functions like int(), float(), str() etc.
#String to int base #int to float conversion #int to complex data type
conversion year = 2021 conversion
print(int(“10001”,2)) print(float(year)) print(complex(1, 2))
Output: 17
Output: 2021.0 Output: (1+2j)
Type Conversions with Between String and Boolean and Other Data
Numeric Data. Numeric Data. Types