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 client or server side?
How the memory is managed in python?
What does __ init __ mean in python?
What is automation in python?
Why is numpy so fast?
What is wrong with the code?
How do you use isalpha in python?
What are local variables in python?
How to comment multiple lines in python?
Explain Inheritance in Python?
What does static pressure mean?
What are decorators in python and how do you use them?
Can I learn python in a month?
How do you insert an object at a given index in python?
How do I watch a file for changes using python?