- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 98字
- 2021-07-02 14:00:28
The range() function
The Python range() function will generate a sequence of numbers. For example, range(10) will generate numbers from 0 to 9 (10 numbers).
We can also define the start, stop, and step size as parameters and range() will be as follows:
range(start, stop, step size).
Step size defaults to 1 if not provided.
For loop example using range() function:
Let's take a look at an example:
for i in range(5):
print("The number is", i)
Output:
The number is 0
The number is 1
The number is 2
The number is 3
The number is 4
推薦閱讀
- Visual C++程序設計教程
- Delphi程序設計基礎:教程、實驗、習題
- JavaScript+DHTML語法與范例詳解詞典
- Java Web開發之道
- 深入理解Java7:核心技術與最佳實踐
- 云計算通俗講義(第3版)
- Unity Game Development Scripting
- Learning Hunk
- Learning Continuous Integration with TeamCity
- HTML+CSS+JavaScript編程入門指南(全2冊)
- OpenStack Networking Essentials
- SciPy Recipes
- Visual Basic語言程序設計基礎(第3版)
- Mastering Object:Oriented Python(Second Edition)
- Microsoft Azure Security