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
Is python dict a hashmap?
How do I run a py file in python shell?
What is the purpose of self?
Is notepad ++ good for python?
What is super () in python?
How is python interpreted language?
How do I delete a file?
What do you know about palindromes? Can you implement one in python?
How can I learn python?
How do I put python to sleep?
Tell me what are different ways to create an empty numpy array in python?
Why lambda forms in python does not have statements?
What does the meaning of slicing in python?
explain the reduce() function?
What are docstrings in python?