In: Computer Science
import math import numpy as np # since you said to ignore the read of csv files i am ignoring it and doing the rest # A,t,s as said in question and d is distance # distance can be calculated normally i.e expected distance covered d=s*t #vd,vertical displacement is sin(theta) of d as python uses radians to compute everything we convert degree to radians #hd,horizontal displacement is cos(theta) of d as python uses radians to compute everything we convert degree to radians hd=d*math.cos(math.radians(A)) vd=d*math.sin(math.radians(A)) #rounding off to 2 dec places hd=round(hd,2) vd=round(vd,2) d=round(d,2) ans=[hd,vd,d] #we need to repeat this whole process for each row so i hope you know it as you said to ignore the csv file part # so for each row in csv file repeat everything. #since we are calculating for each row the numpy array would be a nd array so we make a list [ans] and append it to finals #The axis is an optional integer along which define how the array is going to be displayed. # If the axis is not specified, the array structure will be flattened finalans = np.append(finalans, [ans], axis = 0)