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 are attributes and methods in a python class?
Is c++ required for learning python?
What is the use of lambda in python?
does recursion cause any trouble?
What is a module in python?
find max length of any given sublist?
What is purpose of __init__ in class ? Is it necessary to use __init__ while creating a class ?
What is module in python?
What is web scraping?
What does == mean in python?
What is the difference between a function and a method python?
What is super () in react?
Which is more powerful python or c++?
Can python be used for automation?
Tell me how does python handle the memory management?