+ 23

What is the difference between XRANGE & RANGE...????

27th Jan 2019, 11:03 AM
Pari
Pari - avatar
11 ответов
+ 21
XRANGE returns the XRANGE object while range returns the same list & uses the same memory & no matter what the range size is....
27th Jan 2019, 11:44 AM
Kshitija Raut
Kshitija Raut - avatar
+ 14
xrange is python 2 only range in python 3 does the same as xrange in python 2
27th Jan 2019, 5:37 PM
Tibor Santa
Tibor Santa - avatar
+ 10
The only difference is that rangereturns a Python list object andxrange returns an xrange object. ... It means that xrange doesn't actually generate a static list at run-time like range does. It creates the values as you need them with a special technique called yielding.
27th Jan 2019, 6:13 PM
Anisa Amin
Anisa Amin - avatar
+ 5
range vs xrange in Python range() and xrange() are two functions that could be used to iterate a certain number of times in for loops in Python. In Python 3, there is no xrange , but the range function behaves like xrange in Python 2.If you want to write code that will run on both Python 2 and Python 3, you should use range(). range() – This returns a list of numbers created using range() function. xrange() – This function returns the generator object that can be used to display numbers only by looping. Only particular range is displayed on demand and hence called “lazy evaluation“. Both are implemented in different ways and have different characteristics associated with them. The points of comparisons are: Return TypeMemoryOperation UsageSpeed Return Type range() returns – the list as return type. xrange() returns – xrange() object.
2nd Feb 2019, 7:40 AM
Danyo Joe Crews Kumi Junior
Danyo Joe Crews Kumi Junior - avatar
+ 4
Python 2: range(a,b) = [a, b] xrange(a,b) = [a, b) In interval notation
28th Jan 2019, 10:09 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
I think there is perhaps no difference in python 3 as xrange is range and range has been deprecated
27th Jan 2019, 11:27 PM
Uddyan Sinha
Uddyan Sinha - avatar
+ 1
Xrange was used in older version and range is used in python 3.
2nd Feb 2019, 11:42 AM
Sapan Gupta
Sapan Gupta - avatar
+ 1
xrange is a legacy function. It doesn't work in python 3 a = xrange(1,20) NameError: name 'xrange' is not defined
18th Apr 2019, 4:09 AM
wave rider
0
XRANGE is a dynamic fact, while RANGE is simple.
31st Jan 2019, 11:54 AM
Rafi Sarker