
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Get the Trigonometric cosine of an angle in Python
To find the Trigonometric cosine, use the numpy.cos() method in Python Numpy. The method returns the sine of each element of the 1st parameter x. The 1st parameter, x, is an Angle, in radians (2pi means 360 degrees). The 2nd and 3rd parameters are optional. The 2nd parameter is an ndarray, A location into which the result is stored.
If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshlyallocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
The 3rd parameter is the condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value.
Steps
At first, import the required library −
import numpy as np
Get the Trigonometric cosine. Finding cosine 90 degrees −
print("\nResult...",np.cos(np.pi/2.))
Finding cosine 60 degrees −
print("\nResult...",np.cos(np.pi/3.))
Finding cosine 45 degrees −
print("\nResult...",np.cos(np.pi/4.))
Finding cosine 30 degrees −
print("\nResult...",np.cos(np.pi/6.))
Finding cosine 0 degrees −
print("\nResult...",np.cos(0))
Example
import numpy as np # To find the Trigonometric cosine, use the numpy.cos() method in Python Numpy # The method returns the sine of each element of the 1st parameter x. This is a scalar if is a scalar. print("Get the Trigonometric cosine...") # finding cosine 90 degrees print("\nResult...",np.cos(np.pi/2.)) # finding cosine 60 degrees print("\nResult...",np.cos(np.pi/3.)) # finding cosine 45 degrees print("\nResult...",np.cos(np.pi/4.)) # finding cosine 30 degrees print("\nResult...",np.cos(np.pi/6.)) # finding cosine 0 degrees print("\nResult...",np.cos(0))
Output
Get the Trigonometric cosine... Result... 6.123233995736766e-17 Result... 0.5000000000000001 Result... 0.7071067811865476 Result... 0.8660254037844387 Result... 1.0
- Related Articles
- Get the Trigonometric inverse cosine in Python
- Get the Trigonometric sin of an angle in Python
- Get the Trigonometric tangent of an angle in Python
- Get the Trigonometric cosine of an array of angles given in degrees with Python
- Get the Trigonometric inverse cosine of the array elements in Python
- Get the arc cosine of an angle in Java
- How to find cosine of an angle using Python?
- Get the Trigonometric sines of an array of angles given in degrees in Python
- Get the Trigonometric tangent of an array of angles given in degrees with Python
- Get the Trigonometric inverse sin in Python
- Get the Trigonometric inverse tangent in Python
- Get the Trigonometric inverse sine of the array elements in Python
- Get the Trigonometric inverse tangent of the array elements in Python
- Get the hyperbolic cosine of a given value in Java
- How to get the cosine of a number in JavaScript?
