How do I convert a string to a number?
Answer / chaitanya
Python contains several built-in functions to convert values from one data type to another data type.
The int function takes string and coverts it to an integer.
>>>s = "1234" # s is string
>>>i = int(s) # string converted to int
>>>print i+2
-------------------------
1236
The float function converts strings into float number.
>>>s = "1234.22" # s is string
>>>i = float(s) # string converted to float
>>>print i
-------------------------
1234.22
| Is This Answer Correct ? | 0 Yes | 0 No |
Explain ternary operator in python?
How can you explicitly free memory in python?
Can we concat bytes to str?
Define pyramid in python?
What is __ main __ in python?
Name few python web application frameworks?
Is pypy faster than python?
Tell me what is dict and list comprehensions are?
What is pandas?
What is anaconda program?
How do I install pip on windows?
Is there a main in python?