+ 1

Is int the only data type that can be used under range?

Python

12th Oct 2019, 5:22 PM
Prince Siabi
Prince Siabi - avatar
4 ответов
+ 6
In python range() can only take integer numbers, float is not possible.
12th Oct 2019, 5:37 PM
Lothar
Lothar - avatar
+ 2
If your question is related to Kotlin, you habe the following options: IntRange, UIntRange, LongRange, ULongRange and CharRange.
12th Oct 2019, 5:31 PM
Michael
Michael - avatar
+ 1
In python you could either define your own floatrange() function, or import the NumPy library and use the numpy.arange() function with the same syntax as the range() function.
12th Oct 2019, 5:50 PM
Michael
Michael - avatar
+ 1
You can also use booleans, but because booleans and small integers require same amount of memory, I think booleans are actually integers in Python, even though they have different class and representation.
12th Oct 2019, 6:18 PM
Seb TheS
Seb TheS - avatar