print("\nprinting the values in degrees") print(np.degrees(sec)) print("\nprinting the tan values of different angles") tanval = np.tan(arr*np.pi/180) print(tanval) print("printing the inverse of the tan") cot = np.arctan(tanval) print(cot) print("\nprinting the values in degre...
2pi Radians = 360 degrees 返回: An array with trignometric cosine of x for all x i.e. array elements 代码1:工作 # Python program explaining#cos() functionimportnumpyasnpimportmath in_array = [0, math.pi /2, np.pi /3, np.pi]print("Input array : \n", in_array) cos_Values = ...
在这个示例中,我们首先创建了一个包含几个角度(以度为单位)的数组angles_degrees。然后,我们将这些角度转换为弧度,并存储在angles_radians数组中。接着,我们使用np.cos函数计算这些角度的余弦值,并将结果存储在cosine_values数组中。最后,我们打印出原始角度和对应的余弦值。 输出或返回计算结果: 在上面的示例中,我们...
in_array = [0, math.pi / 2, np.pi / 3, np.pi] print ("Input array : \n", in_array) cos_Values = np.cos(in_array) print ("\nCosine values : \n", cos_Values) 输出: Input array : [0, 1.5707963267948966, 1.0471975511965976, 3.141592653589793] Cosine values : [ 1.00000000e+00...
array : [array_like]elements are in radians. 2pi Radians = 360 degrees 返回:An array with trigonometric cosine of x for all x i.e. array elements 代码#1:工作计算机编程语言# Python program explaining # cos() function import numpy as np import math in_array = [0, math.pi / 2, np....
21.Write a NumPy program to compute the trigonometric sine, cosine and tangent array of angles given in degrees. Sample output: sine: array of angles given in degrees [ 0. 0.5 0.70710678 0.8660254 1. ] cosine: array of angles given in degrees ...
degrees(inv) print '\n' print 'Tan function:' tan = np.tan(a*np.pi/180) print tan print '\n' print 'Inverse of tan:' inv = np.arctan(tan) print inv print '\n' print 'In degrees:' print np.degrees(inv) 复制 它的输出如下 - Array containing sine values: [ 0. 0.5 ...
def pythonsum(n):a = range(n)b = range(n)c = []for i in range(len(a)):a[i] = i ** 2b[i] = i ** 3c.append(a[i] + b[i])return c 以下是使用 NumPy 实现的函数: def numpysum(n):a = numpy.arange(n) ** 2b = numpy.arange(n) ** 3c = a + breturn c ...
In: m.shape Out: (2, 2) 我们使用arange()函数创建了一个2 x 2的数组。 没有任何警告,array()函数出现在舞台上。 array()函数从提供给它的对象创建一个数组。 该对象必须是类似数组的,例如 Python 列表。 在前面的示例中,我们传入了一个数组列表。 该对象是array()函数的唯一必需参数。 NumPy 函数倾向...
输出: Input array:[0,1.5707963267948966,1.0471975511965976,3.141592653589793]Cosine values:[1.00000000e+006.12323400e-175.00000000e-01-1.00000000e+00] 代码#2:图形表示 Python # Python program showing# Graphical representation of# cos() functionimportnumpyasnpimportmatplotlib.pyplotasplt in_array=np.linspace(...