2nd Semester Intro to Computer Science

Do Now 4.02

1. In your Console

Type the following code

for i in range(0, 10):
    print(i)

In your Notebook

Respond to the following

Write down what the range function does.

2. In your Console

Type the following

Use the range and len functions to make a for loop that loops through a.

a = ['apples', 'oranges', 'pears', 'grapes']

len_a = len(a)
range(0, len(a))

Continue In your Notebook

  1. Write down what range(0, len(a)) does.
  2. What is the return value of the range function?

3. In your Console

Use the range and len functions to make a for loop. (Remember that for loops iterate over lists)

Edit this page Report an issue