[go: up one dir, main page]

0% found this document useful (0 votes)
5 views9 pages

For Loop

The document explains the use of the range() function in for loops to generate sequences of numbers with one, two, or three arguments. It provides examples of generating numbers and printing asterisks based on a specified range. The document illustrates how to control the start, stop, and step values in a for loop.

Uploaded by

Sushi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views9 pages

For Loop

The document explains the use of the range() function in for loops to generate sequences of numbers with one, two, or three arguments. It provides examples of generating numbers and printing asterisks based on a specified range. The document illustrates how to control the start, stop, and step values in a for loop.

Uploaded by

Sushi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

For loop

Using range() with For Loop


The range() function is commonly used with for loops to generate a sequence of
numbers. It can take one, two, or three arguments:
• range(stop): Generates numbers from 0 to stop-1.
• range(start, stop): Generates numbers from start to stop-1.
• range(start, stop, step): Generates numbers from start to stop-1, incrementing by
step.
for i in range(0, 10, 2):
print(i)

1
2
3
4
5
N=5
For I in range( N):
Print(“*”)

COLUMN ROWS

6
7
8
9

You might also like