[python] Using PI in python 2.7

I am trying to access the value of pi in Python 2.7, but it seems as if Python doesn't recognize math.pi. I am using IDLE, and when I try to print the value of math.pi, it says that "Math is not defined" or "math is not defined". I can't upgrade to the next version without risk, so is there a way to access pi in Python 2.7? Alternatively, is there another way to convert degrees to radians in Python 2.7 without dealing with Pi?

This question is related to python python-2.7

The answer is


To have access to stuff provided by math module, like pi. You need to import the module first:

import math
print (math.pi)