DATA170
Exploring Data

Activity 6

Array Operations

  1. Without using numpy, write the Python function geo_sum(n) that returns the sum of the first n terms of the series:

    $$\frac{1}{1} + \frac{1}{2} + \frac{1}{4} + \frac{1}{8} + \frac{1}{16} + \ldots$$

    print(geo_sum(1)) # 1.0
    print(geo_sum(3)) # 1.75
    print(geo_sum(5)) # 1.9375
  2. Using numpy and no loops, write the geo_sum(n) function.