About 10,100,000 results
Open links in new tab
  1. python - How do I convert all of the items in a list to floats? - Stack ...

    632 [float(i) for i in lst] to be precise, it creates a new list with float values. Unlike the map approach it will work in py3k.

  2. python - How do I parse a string to a float or int? - Stack Overflow

    Dec 19, 2008 · For the reverse, see Convert integer to string in Python and Converting a float to a string without rounding it. Please instead use How can I read inputs as numbers? to close duplicate …

  3. Checking if a string can be converted to float in Python

    Apr 10, 2009 · TL;DR: If your input is mostly strings that can be converted to floats, the try: except: method is the best native Python method. If your input is mostly strings that cannot be converted to …

  4. python - Check if a number is int or float - Stack Overflow

    Notice that Python 2 has both types int and long, while Python 3 has only type int. Source. If you want to check whether your number is a float that represents an int, do this

  5. How to convert int to float in python? - Stack Overflow

    Nov 27, 2015 · float_version = float(int_version) The reason you are getting 0 is that Python 2 returns an integer if the mathematical operation (here a division) is between two integers. So while the division …

  6. Safest way to convert float to integer in python? - Stack Overflow

    Aug 2, 2010 · Python's math module contain handy functions like floor & ceil. These functions take a floating point number and return the nearest integer below or above it. However these functions …

  7. python - How to get a random number between a float range ... - Stack ...

    May 22, 2011 · random.randrange(start, stop) only takes integer arguments. So how would I get a random number between two float values?

  8. Convert list or numpy array of single element to float in python

    float(np.asarray(list_)) And this works when list_ is both a Python list and when it is a numpy array. Question But it seems like this approach has an overhead first converting the list to a numpy array …

  9. python - Why does integer division yield a float instead of another ...

    I understand the reason why Python does it in the instances of the answer not being #.0, but not for instances where the answer is #.0. Float 1.0 is the same as integer 1, so when the numbers being …

  10. What is the point of float('inf') in Python? - Stack Overflow

    Dec 14, 2015 · Just wondering over here, what is the point of having a variable store an infinite value in a program? Is there any actual use and is there any case where it would be preferable to use foo = …