Sitemap

Topic : Type Conversion

2 min readAug 30, 2026

--

DEFINITION :

Type conversion is a technique used to change or convert a data value from one data type to another data type.

For Example :

  • Integer > Float
  • String > Integer
  • Integer > String

Type Conversion is divided into 2 types :

  1. IMPLICIT
  2. EXPLICIT

EXPLANATION :

  1. IMPLICIT :

Implicit type conversion is the process where python engine automatically converts one data type into another data type without the need of a programmer for execution.

“During implicit type conversion, Python engine follows the rules of type precedence to determine the resulting data type.”

The advantage of this data type is the data will be safe & it will never be vanished

Example :

when an integer and a float are used together, Python converts the integer to a float because float has higher type precedence in this context.

X=10      THIS IS AN INTEGER
Y=10.3 THIS IS AN FLOAT
Z=X+Y WHILE ADDING BOTH FLOAT HAS HIGH PRECEDENCE
SO INTEGER IS CONVERTED INTO FLOAT

OUTPUT: Z=20.3
X=10.3   
Y=5+2j
Z=X+Y

OUTPUT:
Z=15.3+2J

2. EXPLICIT :

Get Sreedevarakondanavya’s stories in your inbox

Join Medium for free to get updates from this writer.

Explicit type conversion means the programmer manually converts a data value from one data type to another data type.

The disadvantage of using this data type is the data will not be safe, we might loss the data.

The programmer uses python inbuilt functions to convert the data type from one data type to another data.

Some of the inbuilt functions are :

  1. int( )
  2. float( )
  3. complex( )
  4. str( )
  5. list( )

In simple words:

Explicit type conversion= The programmer tells Python engine to change the data type

EXAMPLES :

  1. Integer > float
x=10
float(x)

OUTPUT: 10.0

2. Float > integer

x=10.3
int(x)

OUTPUT: 10

3. Float > complex

x=5.3
complex(x)

OUTPUT:5.3+1J

4. Integer > float > complex

x=10
y=5.3
complex(x+y)

OUTPUT: 15.3+1J

--

--