day1/exercise/funcs2.py
author Prabhu Ramachandran <prabhu@aero.iitb.ac.in>
Sat, 19 Jun 2010 01:27:20 -0400
branchscipy2010
changeset 409 4442da6bf693
parent 64 333092b68926
permissions -rw-r--r--
ENH: Minor cleanup. Also added slide to introduce IPython's %timeit and %time.

import math

def linspace(a, b, N):
    lns = []
    step = (float(b) - float(a)) / float(N - 1)
    print step
    for i in range(N):
        lns.append(a + i*step)

    return lns

def sin_func():
    x = linspace(0, 5, 11)
    sin_list = []
    for i in x:
        sin_list.append(math.sin(i))

    print sin_list

def sinsin_func():
    x = linspace(0, 5, 11)
    sin_list = []
    for i in x:
        sin_list.append(math.sin(i) + math.sin(10*i))

    print sin_list

sinsin_func()