Write a Python program to convert degree to radian


This Python code converts a degree value to its equivalent in radians. Here's an explanation of each part of the code

  • import math: This line imports the math module, which provides various mathematical functions and constants.
  • degree = float(input("Enter Degree value : ")): This line prompts the user to enter a degree value and stores it as a floating-point number in the variable degree.
  • radian = math.radians(degree): This line calculates the equivalent radian value for the entered degree. It uses the math.radians() function from the math module, which takes a degree value as input and returns its radian equivalent.
  • print("Degree to Radian : ", radian): Finally, this line prints the result, which is the radian value corresponding to the degree value entered by the user. The text "Degree to Radian" is included in the output to clarify the unit of measurement.

Overall, this code takes a degree value as input, converts it to radians using the math.radians() function, and then prints the converted value. It's a common operation when working with trigonometric calculations and geometry in mathematics and science

Source Code

"""
#Solution-1:
pi=3.14
d = float(input("Ente the Degrees : "))
r = d*(pi/180)
print(r)
 
#Solution-2:
from math import pi
deg = 90
print( (deg * pi) / 180.0)
"""
 
#Solution-3:
import math
 
# Input degree value
degree = float(input("Enter Degree value : "))
 
# Convert degrees to radians
radian = math.radians(degree)
print("Degree to Radian : ",radian)

Output

Enter Degree value : 90
Degree to Radian :  1.5707963267948966

Example Programs