Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of the xrange () function in python

Shulou Source: shulou.com Published: 2022-06-01 02:32:15 09月21日 Update

This article will explain in detail what is the use of the xrange () function in python. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Xrange () function

Xrange (): similar to range (), but instead of creating a list, it returns a xrange object that behaves like a list, but only calculates list values when needed, saving memory when the list is large.

> a = xrange (10) > print a [0] 0 > print a [1] 1 > print a [9] what are the advantages of Python? compared with traditional languages such as C 9Python +, Java, C #, etc., Python has less stringent requirements on code format; 2. Python is open source and everyone can see the source code and can be ported to many platforms. 3, Python object-oriented, can support process-oriented programming, also support object-oriented programming; 4, Python is an explanatory language, the program written by Python does not need to be compiled into binary code, can run the program directly from the source code; 5, Python is powerful, has many modules, basically can achieve all the common functions.

This is the end of the article on "what is the use of the xrange () function in python". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Tags: Functions objects articles code functions more source code programs languages support programming good practical powerful large similar binary advantages traditional memory Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno MariaDB macOS Shulou Information