Page 197 - AI Ver 3.0 Class 11
P. 197
3. Write a Python program to accept the 3 sides of a triangle. Check and display whether the triangle is
Equilateral, Isosceles or Scalene. [CBSE HANDBOOK]
The range() Function
The range() function in Python generates a sequence of numbers. It is commonly used with for loops to iterate over
a specific range of numbers. The syntax of the range function is as follows:
range(start, stop, step)
where,
• • start: Starting number of the sequence.
• • stop: Generate numbers up to, but not including the last number.
• • step: Difference between each number in the sequence.
Python use range( ) function in three ways:
1. range(stop): This generates a sequence of numbers from 0 up to the specified stop value but not including it.
It implicitly starts from 0 and increments by 1.
Program 20: To demonstrate the use of a range () with only stop value
for i in range(5):
print(i)
Output:
0
1
2
3
4
2. range(start, stop): This generates a sequence of number beginning with start and going up to stop, but not
including the specified stop value. It increments by 1 step.
Program 21: To demonstrate the use of a range () with start and stop values
for i in range(20, 25):
print(i)
Python Programming 195

