Repository navigation
Expand file tree
/
Copy path048-Range-Start-and-Step.py
More file actions
60 lines (49 loc) · 1.64 KB
/
Copy path048-Range-Start-and-Step.py
File metadata and controls
60 lines (49 loc) · 1.64 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 Start and Step
===============================================================================
Program Description:
--------------------
This program demonstrates the use of the range() function with
start, stop, and step values.
The sequence starts from the specified start value and increases
by the specified step value until it reaches the stop value.
The stop value is not included in the sequence.
Syntax:
range(start, stop, step)
Example:
range(2, 11, 2)
Output:
2
4
6
8
10
Author : Shaik Mahaboob Basha
Repository : 13-Python
File Name : 48-Range-Start-and-Step.py
===============================================================================
"""
# -----------------------------------------------------------------------------
# Displaying a heading.
# -----------------------------------------------------------------------------
print("Even Numbers from 2 to 10")
# Output: Even Numbers from 2 to 10
# -----------------------------------------------------------------------------
# Using the range() function with start, stop, and step values.
# -----------------------------------------------------------------------------
for number in range(2, 11, 2):
# The loop variable stores one value at a time.
print(number)
# Output:
# 2
# 4
# 6
# 8
# 10
# -----------------------------------------------------------------------------
# Displaying a message after the loop.
# -----------------------------------------------------------------------------
print("Program Completed.")
# Output:
# Program Completed.