Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
I want to obtain the value of pi in Python 2.7, but it appears as if Python doesn't acknowledge math.pi. I am working with IDLE, and when I try to display the value of math.pi with the help of the print statement, it says that "Math is not defined" or "math is not defined".

1 Answer

0 votes
by (108k points)

You need to first import the math package then you can able to use the .pi:

Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> import math

>>> math.pi

3.141592653589793

Python also comes with batteries incorporated, of course:

>>> math.radians(90)

1.5707963267948966

>>> math.radians(180)

3.141592653589793

Interested in learning Python? Enroll in our Python Course that will guide you in a better way! 

Related questions

0 votes
1 answer
0 votes
1 answer
asked Sep 23, 2019 in Python by Sammy (47.6k points)

Browse Categories

...