Answer Posted / 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 |
Post New Answer View All Answers
What is input () in python?
List out loop breaking functions?
Is nan a float python?
How to append to a string in Python?
How to sort a dictionary by key in python?
What is pip and when it is used ?
How do you find missing values in python?
Are uuids sequential?
What is difference between sort and sorted in python?
What are the benefits of using python? What do you understand of pep 8?
Is python a keyword in python?
What if you want to toggle case for a python string?
What are python modules?
What is self and init in python?
What are the tools that help to find bugs or perform analysis?