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

Does python have polymorphism?

0 Answers  


What is deep copy in python?

0 Answers  


Can we use else block with for loop? Answer with one example.

0 Answers  


What objects are iterable in python?

0 Answers  


How are data types defined in python?

0 Answers  


What is a function for flatten an irregular list of lists?

0 Answers  


How do you split a list into evenly sized chunks?

0 Answers  


Is python the future of programming?

0 Answers  


What statement is used in python if the statement is required syntactically but no action is required for the program?

0 Answers  


Convert a string representation of list to list.

0 Answers  


What is sphinx linux?

0 Answers  


How can you randomize the items of a list in place in python?

0 Answers  


Categories