View Discussion
Improve Article
Save Article
View Discussion
Improve Article
Save Article
degrees[] and radians[] are methods specified in math module in Python 3 and Python 2.
Often one is in need to handle mathematical
computation of conversion of radians to degrees and vice-versa, especially in the field of geometry. Python offers inbuilt methods to handle this functionality. Both the functions are discussed in this article.
radians[]
This function accepts the “degrees” as input and converts it into its radians equivalent.
Syntax : radians[deg] Parameters : deg : The degrees value that one needs to convert into radians Returns : This function returns the floating point radians equivalent of argument. Computational Equivalent : 1 Radians = 180/pi Degrees.
Code #1 : Demonstrating radians[]
Python3
import
math
print
["
180
/
pi Degrees
is
equal to Radians : ", end
=
""]
print
[math.radians[
180
/
math.pi]]
print
["
180
Degrees
is
equal to Radians : ", end
=
""]
print
[math.radians[
180
]]
print
["
1
Degrees
is
equal to Radians : ", end
=
""]
print
[math.radians[
1
]]
Output:
180/pi Degrees is equal to Radians : 1.0 180 Degrees is equal to Radians : 3.141592653589793 1 Degrees is equal to Radians : 0.017453292519943295
degrees[]
This function accepts the “radians” as input and converts it into its degrees equivalent.
Syntax : degrees[rad] Parameters : rad : The radians value that one needs to convert into degrees. Returns : This function returns the floating point degrees equivalent of argument. Computational Equivalent : 1 Degrees = pi/180 Radians.
Code #2 : Demonstrating degrees[]
Python3
import
math
print
["pi
/
180
Radians
is
equal to Degrees : ", end
=
""]
print
[math.degrees[math.pi
/
180
]]
print
["
180
Radians
is
equal to Degrees : ", end
=
""]
print
[math.degrees[
180
]]
print
["
1
Radians
is
equal to Degrees : ", end
=
""]
print
[math.degrees[
1
]]
Output:
pi/180 Radians is equal to Degrees : 1.0 180 Radians is equal to Degrees : 10313.240312354817 1 Radians is equal to Degrees : 57.29577951308232
Application : There are many possible applications of these functions in mathematical computations related to geometry and has a certain applications in astronomical computations as well.
❮ Math Methods
Example
Find the sine of different numbers:
# Import math Library
import math
# Return the sine of different values
print [math.sin[0.00]]
print [math.sin[-1.23]]
print [math.sin[10]]
print [math.sin[math.pi]]
print [math.sin[math.pi/2]]
Try it Yourself »
Definition and Usage
The math.sin[]
method returns the sine of a number.
Note: To find the sine of degrees, it must first be converted into radians with the
math.radians[]
method [see example below].
Syntax
Parameter Values
x | Required. The number to find the sine of. If the value is not a number, it returns a TypeError |
Technical Details
A float value, from -1 to 1, representing the sine of an angle
|
1.4 |
More Examples
Example
Find the sine of different degrees:
# Import math Library
import math
# Return the sine value of 30 degrees
print[math.sin[math.radians[30]]]
# Return the sine value of 90 degrees
print[math.sin[math.radians[90]]]
Try it Yourself »
❮ Math Methods