- 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
推薦閱讀
- 密碼學原理與Java實現
- 大學計算機基礎實驗教程
- 無代碼編程:用云表搭建企業數字化管理平臺
- Developing Middleware in Java EE 8
- Hands-On JavaScript High Performance
- Reactive Programming With Java 9
- 軟件架構:Python語言實現
- Mastering Android Development with Kotlin
- 大話Java:程序設計從入門到精通
- C指針原理揭秘:基于底層實現機制
- 算法秘籍
- Learning Kotlin by building Android Applications
- Learning Alfresco Web Scripts
- 讓Python遇上Office:從編程入門到自動化辦公實踐
- 微信小程序開發圖解案例教程:附精講視頻(第3版)