Type Casting Data Types in Python

Type Casting Data Types in Python. A Python program to print the typecasting int string and float value. In this program, we can print the typecast value in python. The integer literal is specified using int(). Using a text literal and Float, create an integer number. The string literal is specified via str(). Create a string type from either an integer or a float literal. The float data types are specified with float().

x = str(3) 
y = int(3)
z = float(3)






Float Value 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.

Int Value in Python

The int() method returns the numerical integer equivalent of a phrase. The expression’s numeric integer equivalent is returned. In this scenario, the decimal component of the number is truncated, and just the integer portion is returned.

Strings in Python

A string is a collection of characters such as alphabets, words, or other symbols. It’s a straightforward data structure that acts as the foundation for data manipulation. Python comes with a string class named str. Strings in Python are “immutable,” which means they can’t be changed once they’ve been created.