Type Casting in Python With Example. A Python program to find the variable type. In this program, we can print the variable in a python programming language. Typecasting is a technique for converting variables/values declared in one data type to a different data type in order for the code snippet to conduct the action necessary. This feature can be achieved in Python by using function Object() functions such as int(), string(), float(), and so on.
x = 5
y = "inlarn"
Int in Python
The int() function calculates the numerical integer equivalent of a specified phrase. The numeric integer equivalent of the expression is returned. The decimal component of the number is truncated in this case, and the integer portion is returned.
Strings in Python
A string is a group of alphabets, words, or other characters. It is a simple data structure that serves as the foundation for data manipulation. Python includes a string class called str. Strings in Python are “immutable,” which means they can’t be modified once they’re produced.
Float in Python
The float() function in Python transforms a number recorded in a string or integer to a floating-point number or a decimal point number. Python has two number types: floating-point numbers (floats) and integers. Integers cannot include decimals, although floats may. In this program we can execute type casting in python