0% found this document useful (0 votes)
8 views10 pages

Using Range Funtion

Uploaded by

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

Using Range Funtion

Uploaded by

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

Using Range() Funtion

The range() function in Python is used to generate a sequence of


numbers, which can be used to iterate over a loop.
The range() function takes three arguments:

•start (optional): The starting value of the sequence (default is 0).


•stop: The ending value of the sequence (this value is not included in
the sequence).
•step (optional): The increment between each number in the sequence
(default is 1).
• In example 1, we use range(5) to generate a sequence of numbers,
and we use a for loop to iterate over the sequence and print each
number.
• In example 1, we use range(5) to generate a sequence of numbers,
and we use a for loop to iterate over the sequence and print each
number.
• In example 2, we use range(2, 6) to generate a sequence of numbers,
and we use a for loop to iterate over the sequence and print each
number.
• In example 2, we use range(2, 6) to generate a sequence of numbers,
and we use a for loop to iterate over the sequence and print each
number.
• In example 3, we use range(1, 10, 2) to generate a sequence of odd
numbers, and we use a for loop to iterate over the sequence and print
each number.
• In example 3, we use range(1, 10, 2) to generate a sequence of odd
numbers, and we use a for loop to iterate over the sequence and print
each number.
• In example 4, we use the list() function to convert the range object
generated by range(5) into a list.
• In example 4, we use the list() function to convert the range object
generated by range(5) into a list.

You might also like