Repository navigation
Expand file tree
/
Copy path044-Range-Only-Start.py
More file actions
60 lines (49 loc) · 1.58 KB
/
Copy path044-Range-Only-Start.py
File metadata and controls
60 lines (49 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""
===============================================================================
Range Only Start
===============================================================================
Program Description:
--------------------
This program demonstrates the use of the range() function with only the
start value.
When only one value is provided to range(), Python treats it as the
stop value. The sequence starts from 0 by default and ends before the
specified value.
Syntax:
range(stop)
Example:
range(5)
Output:
0
1
2
3
4
Author : Shaik Mahaboob Basha
Repository : 13-Python
File Name : 44-Range-Only-Start.py
===============================================================================
"""
# -----------------------------------------------------------------------------
# Displaying a heading.
# -----------------------------------------------------------------------------
print("Numbers Generated Using range(5)")
# Output: Numbers Generated Using range(5)
# -----------------------------------------------------------------------------
# Using the range() function with only one value.
# -----------------------------------------------------------------------------
for number in range(5):
# The loop variable stores one value at a time.
print(number)
# Output:
# 0
# 1
# 2
# 3
# 4
# -----------------------------------------------------------------------------
# Displaying a message after the loop.
# -----------------------------------------------------------------------------
print("Program Completed.")
# Output:
# Program Completed.