Repository navigation
Expand file tree
/
Copy path046-Range-Only-Step.py
More file actions
59 lines (48 loc) · 1.54 KB
/
Copy path046-Range-Only-Step.py
File metadata and controls
59 lines (48 loc) · 1.54 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 Step
===============================================================================
Program Description:
--------------------
This program demonstrates the use of the range() function with
start, stop, and step values.
The step value specifies how much the value increases after each
iteration.
Syntax:
range(start, stop, step)
Example:
range(1, 10, 2)
Output:
1
3
5
7
9
Author : Shaik Mahaboob Basha
Repository : 13-Python
File Name : 46-Range-Only-Step.py
===============================================================================
"""
# -----------------------------------------------------------------------------
# Displaying a heading.
# -----------------------------------------------------------------------------
print("Odd Numbers from 1 to 9")
# Output: Odd Numbers from 1 to 9
# -----------------------------------------------------------------------------
# Using the range() function with start, stop, and step values.
# -----------------------------------------------------------------------------
for number in range(1, 10, 2):
# The loop variable stores one value at a time.
print(number)
# Output:
# 1
# 3
# 5
# 7
# 9
# -----------------------------------------------------------------------------
# Displaying a message after the loop.
# -----------------------------------------------------------------------------
print("Program Completed.")
# Output:
# Program Completed.