How do I convert a string to a number?
Answer / 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 |
You are having multiple memcache servers running python, in which one of the memcacher server fails, and it has your data, will it ever try to get key data from that one failed server?
What is a python module?
Write code to print only upto the letter t.
What is the __ init __ method used for?
Why do we need tuples?
Is python a keyword in python?
What is @property in python?
How memcached should not be used in your python project?
Write a sorting algorithm for a numerical dataset in python.
Does return print in python?
What is an egg in python?
Why do we use raw_input in python?