Degrees() and Radians() in Python

Given a list, the task is to print the Degrees and Radians value of every element in the given list in Python.

In this article, you will learn about Python’s degrees() and radians() methods. The data will be converted to degrees() and radians() in Python by using the math module. Ship position, etc., will be used for mathematical solving.

Degrees:

The degrees are a unit of angle measurement, and all angels utilize them. If you learn that a circle has 360 degrees, you will be able to use it.

The degree symbol will be obtained by using the Chr(176) technique.

Radians:

In trigonometry, it is a unit of measure of angels that will be used instead of degrees, whereas the circle contains only 360 degrees, a full circle is just over 6 radians. A complete circle has two pi radians.

Examples:

Example1:

Input:

Given list = [8, 1, 9, 12, 45, 1, 7, 3]

Output:

The degree value of the element 8  =  458.3662361046586
The radians value of the element 8  =  0.13962634015954636
The degree value of the element 1  =  57.29577951308232
The radians value of the element 1  =  0.017453292519943295
The degree value of the element 9  =  515.662015617741
The radians value of the element 9  =  0.15707963267948966
The degree value of the element 12  =  687.5493541569879
The radians value of the element 12  =  0.20943951023931956
The degree value of the element 45  =  2578.3100780887044
The radians value of the element 45  =  0.7853981633974483
The degree value of the element 1  =  57.29577951308232
The radians value of the element 1  =  0.017453292519943295
The degree value of the element 7  =  401.07045659157626
The radians value of the element 7  =  0.12217304763960307
The degree value of the element 3  =  171.88733853924697
The radians value of the element 3  =  0.05235987755982989

Example2:

Input:

Given list = [1 ,9 ,7 ,8 ,3 ,6 ,4 ,5 ,11]

Output:

The degree value of the element 1 = 57.29577951308232
The radians value of the element 1 = 0.017453292519943295
The degree value of the element 9 = 515.662015617741
The radians value of the element 9 = 0.15707963267948966
The degree value of the element 7 = 401.07045659157626
The radians value of the element 7 = 0.12217304763960307
The degree value of the element 8 = 458.3662361046586
The radians value of the element 8 = 0.13962634015954636
The degree value of the element 3 = 171.88733853924697
The radians value of the element 3 = 0.05235987755982989
The degree value of the element 6 = 343.77467707849394
The radians value of the element 6 = 0.10471975511965978
The degree value of the element 4 = 229.1831180523293
The radians value of the element 4 = 0.06981317007977318
The degree value of the element 5 = 286.4788975654116
The radians value of the element 5 = 0.08726646259971647
The degree value of the element 11 = 630.2535746439055
The radians value of the element 11 = 0.19198621771937624

Degrees() and Radians() in Python

Below are the ways to print the Degrees and Radians value of every element in the given list in Python.

Are you wondering how to seek help from subject matter experts and learn the Java language? Go with these Basic Java Programming Examples and try to code all of them on your own then check with the exact code provided by expert programmers.

Method #1: Using For Loop and Built-in Math Functions (Static Input)

Approach:

  • Import the math function using the import function.
  • Give the list as static input and store it in a variable.
  • Traverse the given list using For loop.
  • Calculate the value of the degree of the given iterator value using math.degrees() function.
  • Calculate the value of the radians of the given iterator value using math.radians () function.
  • Print the degree and radians value of the element.
  • The Exit of the Program.

Below is the implementation:

# Import the math function using the import function.
import math
# Give the list as static input and store it in a variable.
givenlist = [8, 1, 9, 12, 45, 1, 7, 3]
# Traverse the given list using For loop.
for elementval in givenlist:
    # Calculate the value of the degree of the given iterator
    # value using math.degrees() function.
    degreevalu = math.degrees(elementval)
    # Calculate the value of the radians of the given iterator value
    # using math.radians () function.
    radianvalu = math.radians(elementval)
    # Print the degree and radians value of the element.
    print('The degree value of the element', elementval, ' = ', degreevalu)
    print('The radians value of the element', elementval, ' = ', radianvalu)

Output:

The degree value of the element 8  =  458.3662361046586
The radians value of the element 8  =  0.13962634015954636
The degree value of the element 1  =  57.29577951308232
The radians value of the element 1  =  0.017453292519943295
The degree value of the element 9  =  515.662015617741
The radians value of the element 9  =  0.15707963267948966
The degree value of the element 12  =  687.5493541569879
The radians value of the element 12  =  0.20943951023931956
The degree value of the element 45  =  2578.3100780887044
The radians value of the element 45  =  0.7853981633974483
The degree value of the element 1  =  57.29577951308232
The radians value of the element 1  =  0.017453292519943295
The degree value of the element 7  =  401.07045659157626
The radians value of the element 7  =  0.12217304763960307
The degree value of the element 3  =  171.88733853924697
The radians value of the element 3  =  0.05235987755982989

Method #2: Using For Loop and Built-in Math Functions (User Input)

Approach:

  • Import the math function using the import function.
  • Give the list as user input using list(),map(),input(),and split() functions.
  • Store it in a variable.
  • Traverse the given list using For loop.
  • Calculate the value of the degree of the given iterator value using math.degrees() function.
  • Calculate the value of the radians of the given iterator value using math.radians () function.
  • Print the degree and radians value of the element.
  • The Exit of the Program.

Below is the implementation:

# Import the math function using the import function.
import math
# Give the list as user input using list(),map(),input(),and split() functions.
# store it in a variable.
givenlist = list(
    map(int, input('Enter some random List Elements separated by spaces = ').split()))
# Traverse the given list using For loop.
for elementval in givenlist:
    # Calculate the value of the degree of the given iterator
    # value using math.degrees() function.
    degreevalu = math.degrees(elementval)
    # Calculate the value of the radians of the given iterator value
    # using math.radians () function.
    radianvalu = math.radians(elementval)
    # Print the degree and radians value of the element.
    print('The degree value of the element', elementval, ' = ', degreevalu)
    print('The radians value of the element', elementval, ' = ', radianvalu)

Output:

Enter some random List Elements separated by spaces = 1 9 7 8 3 6 4 5 11
The degree value of the element 1 = 57.29577951308232
The radians value of the element 1 = 0.017453292519943295
The degree value of the element 9 = 515.662015617741
The radians value of the element 9 = 0.15707963267948966
The degree value of the element 7 = 401.07045659157626
The radians value of the element 7 = 0.12217304763960307
The degree value of the element 8 = 458.3662361046586
The radians value of the element 8 = 0.13962634015954636
The degree value of the element 3 = 171.88733853924697
The radians value of the element 3 = 0.05235987755982989
The degree value of the element 6 = 343.77467707849394
The radians value of the element 6 = 0.10471975511965978
The degree value of the element 4 = 229.1831180523293
The radians value of the element 4 = 0.06981317007977318
The degree value of the element 5 = 286.4788975654116
The radians value of the element 5 = 0.08726646259971647
The degree value of the element 11 = 630.2535746439055
The radians value of the element 11 = 0.19198621771937624

Related Programs: