Differentiate between range and xrange.

Answer Posted / nashiinformaticssolutions

Functionality-wise, xrange and range are nearly identical. Both of these let you create an integer list that you may use however you like. The only distinction between xrange and range is that x range returns an xrange object, whereas range returns a Python list object. Range will use as much memory as possible to produce your array of numbers, which can result in a memory error and crash your program. This is particularly true if you are working with a device that needs a lot of memory, like a phone. It has a memory issue and is a beast.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain list, tuple, set, and dictionary and provide at least one instance where each of these collection types can be used.

665


Explain me what are the principal differences between the lambda and def?

632


Why lambda forms in python does not have statements?

679


Explain about membership operator in python?

613


How does inheritance work in python?

670






How to capitalize the first letter of each word in a string (python)?

647


What advantages do numpy arrays offer over (nested) python lists?

756


How can I learn python for free?

576


Is it possible to inherit one class from another class?

566


What is the process to calculate percentiles with numpy?

588


How do I list all files of a directory?

612


What does __ name __ mean in python?

574


Explain split() methods of "re" module in python?

667


What is the difference between numpy and scipy?

565


What is super method in python?

598