0% found this document useful (0 votes)
16 views

What Is Type Casting in Python

The document discusses type casting in Python programming. It explains that type casting allows changing one variable type to another using constructor functions like int(), string(), and float(). It also describes implicit type casting, where Python automatically converts data types, and explicit type casting, where the user explicitly converts variable types using constructor operators.

Uploaded by

viralvision2025
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

What Is Type Casting in Python

The document discusses type casting in Python programming. It explains that type casting allows changing one variable type to another using constructor functions like int(), string(), and float(). It also describes implicit type casting, where Python automatically converts data types, and explicit type casting, where the user explicitly converts variable types using constructor operators.

Uploaded by

viralvision2025
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1

WHAT IS
TYPE CASTING
IN
PYTHON
PROGRAMMING?
2

What is Type Casting?

Type Casting helps in changing one type of


variable in to other.

In python, this feature can be accomplished by


using constructor functions like int(), string(),
float(), etc.
3

Two Types of "Type Casting"

1. Implicit Type Casting

2. Explicit Type Casting


4

Implicit Type Casting

In this, Python converts data type into


another data type automatically. Users
don’t have to involve in this process.

# Python automatically converts data type


of 'a'

a = 9 + 10.5

Here python automatically converts 9 to 9.0


and add 10.5 to it making the answer 19.5
5

Explicit Type Casting


In this user explicitly convert the variable
data type into certain data type using
constructor operators

# int variable
a=5

# typecast to float
n = float(a)

Here user explicitly converted 'n' data type


to 'float'
Visit www.techlearn.live for Free technical session on
Deep learning, Data Science etc

Turn notifications on
Like
Leave a comment
Share
Save for later

@techlearn.live

You might also like