You can either use:

[x / 10.0 for x in range(5, 50, 15)]

or use lambda / map:

map(lambda x: x/10.0, range(5, 50, 15))
Answer from Grzegorz Rożniecki on Stack Overflow
🌐
Codingem
codingem.com › home › range of floats in python: a step-by-step guide (3 ways to do it)
Range of Floats in Python: A Step-by-Step Guide (3 Ways to Do It)
November 1, 2022 - To create a range of floats in Python, use a list comprehension. For example: [(x/10) for x in range(0, 5)] returns [0.0, 0.1, 0.2, 0.3, 0.4]
Discussions

Float contained in range - Ideas - Discussions on Python.org
I have found that checking if a float number falls inside a range() doesn’t work, always giving False: >>> 1.0 in range (0, 2) True >>> 1.5 in range (0, 2) False I can understand that range() can only accept integer values, but checking if it contains a float number should works. More on discuss.python.org
🌐 discuss.python.org
0
September 7, 2023
float numbers with range () function
Yes, range(0, 101) literally gives the integers from 0 to 100. If you want to know if a number is between two values, use a chained comparison: while 0 <= score < 101: Although note you shouldn't get an actual error, just a False. What exact error message did you see? More on reddit.com
🌐 r/learnpython
4
2
April 19, 2022
How to step by floats in a range function?
A somewhat “hacky” way to accomplish this using range directly is by multiplying start/end/step by a power of 10 so they’re all integers, then dividing by that same power in your loop. Do note that range doesn’t include the right endpoint. e.g. for degrees in range(0,3600,225): print(degrees/10) You could also form the step-size on your own and use range to get a multiple of it. E.g. if I wanted to cut [1,2] into 17 pieces, I could do for multiple in range(18): x = 1+(multiple/17) print(x) or just use numpy.linspace. More on reddit.com
🌐 r/learnpython
10
5
November 11, 2020
Fast path for "float in range" checks - Ideas - Discussions on Python.org
Proposal: Add a fast arithmetic path for __contains__ check of floats on range objects. Why: Currently the range() object already performs an arithmetic-based fast path for __contains__ checks of int values, but not float and integral float values. This results in very long comparisons for ... More on discuss.python.org
🌐 discuss.python.org
1
August 16, 2022
🌐
PYnative
pynative.com › home › python › python range of float numbers
Python range of float numbers
April 13, 2021 - NumPy doesn’t come with default Python installation. You can install it using pip install numpy. ... Import numpy module using the import numpy as np statement. ... Pass float numbers to its start, stop, and step argument.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-range-for-float-numbers
Python - range() for Float Numbers - GeeksforGeeks
July 23, 2025 - It behaves like a generator and allows us to loop through float numbers. If we want to create a range with float numbers, we can use a while loop.
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › python range() with float values
Python range() with float values - Spark By {Examples}
May 31, 2024 - If we pass the float value, TypeError will be returned. ... You can see TypeError is returned. As range() doesn’t support float values, you can use the NumPy arange() method which will generate the range of float numbers.
🌐
Python.org
discuss.python.org › ideas
Float contained in range - Ideas - Discussions on Python.org
September 7, 2023 - I have found that checking if a float number falls inside a range() doesn’t work, always giving False: >>> 1.0 in range (0, 2) True >>> 1.5 in range (0, 2) False I can understand that range() can only accept integer va…
🌐
TechBeamers
techbeamers.com › python-float-range
Generate Floating Point Range in Python - TechBeamers
November 30, 2025 - Do you wish to learn how to generate a float range of numbers in Python? In this tutorial, you will find many ways to produce floating point values within a…
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › float numbers with range () function
r/learnpython on Reddit: float numbers with range () function
April 19, 2022 -

Hi, I have a section of code which takes a score from the user, typecasts it into a float value and saves it under the variable name "score". Then I have a line of code which reads:

while score not in range(0, 101):

However, when I input a float, I get an invalid input error message from python. I think it's because I can't use the range() function with floats. Is there a way around this? If anyone knows how to solve this, then your help would be greatly appreciated. Thank you in advance.

🌐
TutorialKart
tutorialkart.com › python › python-range › python-range-float
Python Range with Floating Point Numbers
January 17, 2021 - During iteration, if we divide each element with the same scaling factor, we get sequence of floating point numbers. ... start = 0 stop = 0.9 step = 0.1 scale = 10 for i in range(int(scale*start), int(scale*stop), int(scale*step)) : print(i/scale) ...
🌐
Delft Stack
delftstack.com › home › howto › python › python range float
How to Get Range of Floating Numbers in Python | Delft Stack
February 2, 2024 - This tutorial demonstrates how to use the range() function to get a sequence of float values in Python
🌐
Coursera
coursera.org › tutorials › python-range
How to Use Range in Python | Coursera
Python range does not support the float type, it only works with integers.
🌐
Guru99
guru99.com › home › python › python range() function: float, list, for loop examples
Python range() Function: Float, List, For loop Examples
August 12, 2024 - The parameter step in range() can be used to increment /decrement the values. By default, it is a positive value 1. So it will always give incremented values. Python gives an error for floating-point numbers as the range() function supports only integer values.
🌐
Python.org
discuss.python.org › ideas
Fast path for "float in range" checks - Ideas - Discussions on Python.org
August 16, 2022 - Proposal: Add a fast arithmetic path for __contains__ check of floats on range objects. Why: Currently the range() object already performs an arithmetic-based fast path for __contains__ checks of int values, but not float and integral float values. This results in very long comparisons for ...
🌐
Javatpoint
javatpoint.com › range-of-float-in-python
Range of float in python - Javatpoint
Range of float in python with tutorial, tkinter, button, overview, canvas, frame, environment set-up, first python program, etc.
🌐
BitDegree
bitdegree.org › learn › best-code-editor › python-range-example-4
How to Make a Python Range With Float Values
Python range only allows integers, but you can make it accept float values by using frange() instead of range(). Learn to create Python range with floats!
🌐
GeeksforGeeks
geeksforgeeks.org › python-range-for-float-numbers
Python – range() for Float Numbers | GeeksforGeeks
December 4, 2024 - If we want to create a range with float numbers, we can use a while loop. This loop will allow us to control the start, stop, and step values, including floats. ... # Initialize the starting, stopping, and stepping values start = 0 stop = 2 step = 0.5 #iterate until 'start' reaches or exceeds 'stop' while start < stop: print(start) start += step ... Generating a random float number in Python means producing a decimal number that falls within a certain range, often between 0.0 and 1.0...
🌐
Note.nkmk.me
note.nkmk.me › home › python
Maximum and Minimum float Values in Python | note.nkmk.me
August 11, 2023 - In Python, the float type is a 64-bit double-precision floating-point number, equivalent to double in languages like C. This article explains how to get and check the range (maximum and minimum values ...
🌐
Readthedocs
floatrange.readthedocs.io
floatrange’s documentation! — floatrange 1.0 documentation
>>> from floatrange import floatrange >>> floatrange(5) floatrange(0.0, 5.0, 1.0) >>> list(floatrange(5)) [0.0, 1.0, 2.0, 3.0, 4.0] >>> list(floatrange(3.2,5.4,0.2)) [3.2, 3.4000000000000004, 3.6, 3.8000000000000003, 4.0, 4.2, 4.4, 4.6000000000000005, 4.800000000000001, 5.0, 5.2] >>> 6 in floatrange(1,8) True >>> 6.1 in floatrange(1,8,1,prec=0.2) True >>> 6.1 in floatrange(1,8,1,prec=0.05) False >>> list(reversed(floatrange(5))) [4.0, 3.0, 2.0, 1.0, 0.0] >>> list(floatrange(10.1,9.7,-0.1)) [10.1, 10.0, 9.9, 9.799999999999999]
🌐
Sololearn
sololearn.com › en › Discuss › 818891 › solved-is-there-a-way-to-generate-a-float-range-list-with-step-
[SOLVED] Is there a way to generate a float range list with step ? | Sololearn: Learn to code for FREE!
I would like to know a way to generate a list like range(0,10) with float example range(pi,2pi,0.01) pythonrangefloat · 27th Oct 2017, 5:15 PM · Zerty · 3 Answers · Answer · + 14 · # You can use numpy arange() for that.