Write a function in python called sinex that takes an array

Write a function in python called sine(x) that takes an array of real numbers x and returns an array f of the values of sin(x).

Solution

import math

def sine(x):
f = []
l = len(x)
for i in range(0, l):
f.append(math.sin(x[i]))
return f;
  
x = [1.5,2.5,3.5,4.5]
print sine(x)

Output:

sh-4.3$ python main.py   

[0.9974949866040544, 0.5984721441039565, -0.35078322768961984, -0.977530117665097]

Write a function in python called sine(x) that takes an array of real numbers x and returns an array f of the values of sin(x).Solutionimport math def sine(x):

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site