Repository navigation
Expand file tree
/
Copy path045-Range-Only-Stop.py
More file actions
59 lines (48 loc) · 1.53 KB
/
Copy path045-Range-Only-Stop.py
File metadata and controls
59 lines (48 loc) · 1.53 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
"""
===============================================================================
Range Only Stop
===============================================================================
Program Description:
--------------------
This program demonstrates the use of the range() function with only the
stop value.
When only the stop value is provided, the sequence starts from 0 by
default and ends before the specified stop value.
Syntax:
range(stop)
Example:
range(5)
Output:
0
1
2
3
4
Author : Shaik Mahaboob Basha
Repository : 13-Python
File Name : 45-Range-Only-Stop.py
===============================================================================
"""
# -----------------------------------------------------------------------------
# Displaying a heading.
# -----------------------------------------------------------------------------
print("Numbers from 0 to 4")
# Output: Numbers from 0 to 4
# -----------------------------------------------------------------------------
# Using the range() function with only the stop 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.