TOPIC 6: Python range ( )
Completion requirements
9. Class Exercise
Exercise 1
Create a range from 0 to 9 and display it as a list.
Exercise 2
Create a range starting from 5 and ending before 15.
Display the result as a list.
Exercise 3
Create a range from 2 to 20 with a step value of 3.
Display the result.
Exercise 4
Write a program that prints the numbers from 1 to 10 using a for loop and the range() function.
Exercise 5
What will be the output of the following code?
print(list(range(3)))
Exercise 6
What is the output?
r = range(0, 10, 2)
print(8 in r)
print(9 in r)
Exercise 7
Find the length of the following range.
r = range(2, 12, 2)
print(len(r))