Radians to Degrees Conversions

The radian is a unit of measure for angles used mainly in trigonometry. It is used as an alternative to degrees.
Whereas, in degrees a full circle is 360 degrees, in radians a full circle is 2π radians:
degrees-to-radians-conversions

It is easy to convert an angle from degrees to radians and vice-versa using the following formulas:
degrees-to-radians-formularadians-to-degrees-formula

Python Challenge


In this challenge we will write a program to convert an angle from degrees to radians or from radians to degrees based on the user’s choice. Our program will:

  • Display a menu of options to the end user.
  • Ask the end-user to choose an option from the menu.
  • Ask the end-user to input an angle in the required unit.
  • Calculate and output the angle in the alternative angle unit.

To structure this program we will make use of 3 subroutines as follows:

  • A menu() function that displays the available options, ask the user for an otpion and return the selected option.
  • A procedure called convertRadiansToDegrees() that ask the user to input an angle in radians, convert this angle using the appropriate conversion formula and output the angle in degrees.
  • A procedure called convertDegreesToRadians() that ask the user to input an angle in degrees, convert this angle using the appropriate conversion formula and output the angle in radians.

We will then write an algorithm to complete this challenge, making use of our three subroutines.

Flowcharts


We have designed the flowcharts for the three subroutines and for the main algorithm.

Flowchart #1Flowchart #2 and #3Flowchart #4
flowchart-radians-to-degrees-menu
flowchart-radians-to-degrees-subroutines
flowchart-radians-to-degrees

Python Code


Your task is to complete the Python code for this challenge, using the flowcharts provided above.

Did you like this challenge?

Click on a star to rate it!

Average rating 4.3 / 5. Vote count: 17

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: , ,