Python Practice › NumPy Programs › Program 94

Cosine of angles

EasyNumPy Programs · 94 of 100

Write a NumPy program to calculate the cosine of angles.

Advertisement
Input
0, 60, 90 degrees
Output
[1.  0.5 0. ]

Approach

  1. np.cos(np.radians(...)).

Solution

Python
import numpy as npprint(np.cos(np.radians([0, 60, 90])).round(3))
Output
[1.  0.5 0. ]

Learn the concept

New to this topic? Read the lesson, then come back.

More numpy programs

← All 100 NumPy Programs

Leave a Comment