Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How do I convert a string to a number?



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

Post New Answer

More Python Interview Questions

How can you convert a number to string?

0 Answers  


List out standard datatypes in python

0 Answers  


Why is this important?

0 Answers  


What is a palindrome number?

2 Answers  


Is python good for making apps?

0 Answers  


What is metadata in python?

0 Answers  


In which field python is used?

0 Answers  


What do you think is the output of the following code fragment?

0 Answers  


Explain the role of repr function.

1 Answers  


How can I find the methods or attributes of an object in python?

1 Answers  


What is the best front end for python?

0 Answers  


What is the significance of ‘self' parameter in an object method? Should we always name this parameter as ‘self'?

0 Answers  


Categories