Write a script that will:

• Call a function to prompt the user for an angle in degrees.
• Call a function to calculate and return the angle in radians. (Note: π radians = 180°)
• Call a function to print the resultWrite all of the functions, also. Put the script and all functions in separate code files.

Respuesta :

Answer:

The solution code is written in Python:

  1. import math  
  2. def getUserInput():
  3.    deg = int(input("Enter an angle in degree: "))
  4.    return deg
  5. def calculateRad(deg):
  6.    return (deg * math.pi) / 180
  7. def printResult(deg, rad):
  8.    print(str(deg) + " is equal to " + str(round(rad,2)) + " radian")
  9. degree = getUserInput()
  10. radian = calculateRad(degree)
  11. printResult(degree, radian)

Explanation:

Since we need a standard Pi value, we import math module (Line 1).

Next, create a function getUserInput to prompt user to input degree (Line 3-5).

Next, create another function calculateRad that take one input degree and calculate the radian and return it as output (Line 7-8).

Create function printResult to display the input degree and its corresponding radian (Line 10-11).

At last, call all the three functions and display the results (Line 13-15).