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?

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


Please Help Members By Posting Answers For Below Questions

What are attributes and methods in a python class?

848


Is c++ required for learning python?

735


What is the use of lambda in python?

845


does recursion cause any trouble?

828


What is a module in python?

867


find max length of any given sublist?

843


What is purpose of __init__ in class ? Is it necessary to use __init__ while creating a class ?

823


What is module in python?

866


What is web scraping?

783


What does == mean in python?

960


What is the difference between a function and a method python?

814


What is super () in react?

838


Which is more powerful python or c++?

772


Can python be used for automation?

840


Tell me how does python handle the memory management?

893