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
Explain the Meaning of a single and double underscore before an object name?
What is numpy logspace?
What is a pass in python?
Why is python oop?
What is the output of the below code?
What is lambda function ?
Explain assert in action?
How to delete a file or folder?
How to terminate a python subprocess launched with shell=true?
What is anagram in python?
Is python interpreted language?
Can I learn python on my own?
Should I learn c++ or python?
What is the purpose of “end” in python?
Have you heard of the yield keyword in python?