day1/exercise/funcs2.py
changeset 64 333092b68926
equal deleted inserted replaced
63:f5eac04a00fe 64:333092b68926
       
     1 import math
       
     2 
       
     3 def linspace(a, b, N):
       
     4     lns = []
       
     5     step = (float(b) - float(a)) / float(N - 1)
       
     6     print step
       
     7     for i in range(N):
       
     8         lns.append(a + i*step)
       
     9 
       
    10     return lns
       
    11 
       
    12 def sin_func():
       
    13     x = linspace(0, 5, 11)
       
    14     sin_list = []
       
    15     for i in x:
       
    16         sin_list.append(math.sin(i))
       
    17 
       
    18     print sin_list
       
    19 
       
    20 def sinsin_func():
       
    21     x = linspace(0, 5, 11)
       
    22     sin_list = []
       
    23     for i in x:
       
    24         sin_list.append(math.sin(i) + math.sin(10*i))
       
    25 
       
    26     print sin_list
       
    27 
       
    28 sinsin_func()