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

What are closures in python?

0 Answers  


What is the type of the given datatype a=1?

0 Answers  


Why python is popular now?

0 Answers  


What is a floating point in python?

0 Answers  


What tuple means?

0 Answers  


What type of language is Python?

2 Answers  


How do you count in python?

0 Answers  


Explain python’s pass by references vs pass by value. (Or) explain about python’s parameter passing mechanism?

0 Answers  


What are built-in types of Python?

3 Answers  


What does tuple mean?

0 Answers  


Explain finally keyword?

0 Answers  


How python supports encapsulation with respect to functions?

0 Answers  


Categories