TYPE casting in python | quick revision

Hope everyone doing great!!

so here we will see TYPE CASTING , i am going to write this for quick revision of TYPE casting concept

TYPE CASTING:

Conversion of one type of value in another type known as TYPE CASTING

Here the list of inbuilt function for type casting:

  1. int()
  2. float()
  3. bool()
  4. str()

1.INT() → used for changing value type in to INT data type

Example:

a = 1.5

print(type(a)) // INT

b = int(a)

print(type(b)) // float

print(b)

2.float() → used for changing value type in to FLOAT data type

Example :

a = 1

print(type(a))//float

b = float(a)

print(type(b))// INT

print(b)

3.bool() → used for changing value type in to BOOL data type

Example:

a = 1

b = 0

b = bool(a)

c = bool(b)

print(b)//True

print(c)//False

4.str() → used for changing value type in to str data type

Example:

a = 1
print(type(a))//int
b = str(a)
print(type(b))//str

here check out this video for quick revision in 60 seconds.

hope you are learning everyday

Application developer|Technical blogger|Youtuber(MASTERMIND CODER)|owner at www.yourtechnicalteacher.com