Fix my fors

Download notebook Interact
import numpy as np

All the cells below have errors in syntax or in logic. A syntax error happens when the code does not correspond to Python’s rules; Python generates an error with some information about which bit of the code caused the problem. A logic error is where the code does run, but does not do what it was intended to do. Run the cells to see the error, and then fix them to work correctly.

# Print the numbers 0 through 2
for my_var in np.arange(3)
    print(my_var)
  File "<ipython-input-2-3d71086f11b3>", line 2
    for my_var in np.arange(3)
                              ^
SyntaxError: invalid syntax

# Add up all the numbers from 3 through 10
total = 0
for i in np.arange(3, 11):
total = total + i
print(total)
  File "<ipython-input-3-3d220a6deb87>", line 4
    total = total + i
        ^
IndentationError: expected an indented block

# Print all the numbers between 5 and 9
for p in 56789:
    print(p)
TypeError                                 Traceback (most recent call last)
   ...
TypeError: 'int' object is not iterable
# Add all numbers from 3 down to -2, inclusive
total = 0
for i = np.arange(3, -4, -1):
    total = total + i
print(total)
  File "<ipython-input-5-60746aa6c764>", line 3
    for i = np.arange(3, -4, -1):
          ^
SyntaxError: invalid syntax

# Add up the squares of all the even numbers from -2 to 20
total = 0
for v in np.arange(-2, 21):
    squared = v ** 2
     total = total + squared
print(total)
  File "<ipython-input-6-6b74b5476833>", line 5
    total = total + squared
    ^
IndentationError: unexpected indent

# Add all the odd numbers from 11 through 21
total = 0
for value in np.arange(11, 21):
    total = total + value
print(total)
155

# Print all the numbers starting from 100, and subtracting 7
# up to the last positive number.  The first three
# numbers you will print will be 100, 93, 86
for i in np.arange(100, 7, 7):
    print(i)
# Add every third number in the inclusive range 1 through 21
total = 0
for i in np.arange(1, 21):
    total = total + 1
print(total)
20