+ 5
Anyone know what is type conversion I am not understand that???? (String or float)
2 Réponses
+ 4
Type conversion is to convert one type to another type
For example
You have input a number (suppose 15 and suppose it is age of any people ) and you want to check input age is less than 18 or not. Here the input will take string value (NOTE --> collection of characters "s" is single character "hello" is string. Anything inside double quotes or single quotes is string for example "15"). Here 18 is an integer value and 15 is string value, if you check condition directly the interpreter will generate an error that is why we need to convert "15" (string) to 15 (int)
SYNTAX
variable_name = input("Enter your number")
variable_name = type(variable_name)
To convert string to integer value
variable_name = int(variable_name)
To convert string to float value
variable_name = float(variable_name)
+ 1
The type conversion process in C is basically converting one type of data type to other to perform some operation. The conversion is done only between those datatypes wherein the conversion is possible ex – char to int and vice versa.