Type Casting
Type Casting
Similar to type conversion, type casting is done when we want to specify a type on a variable.
Example:
Output:
Similar to type conversion, type casting is done when we want to specify a type on a variable.
Example:
str1 = "7"
str2 = "3.142"
str3 = "13"
num1 = 29
num2 = 6.67
print(int(str1))
print(float(str2))
print(float(str3))
print(str(num1))
print(str(num2))
Output:
7
3.142
13.0
29
6.67
Sorry, we detected that you have activated Ad-Blocker.
Please consider supporting us by disabling your Ad-Blocker, it helps us in developing this Website.
Thank you!