r/pycharm • • Jun 14 '21

How can I import the Math function?

Post image
4 Upvotes

9 comments sorted by

21

u/[deleted] Jun 14 '21

You have a few choices. You have imported math, but to use pi you have to call it math.pi as it is the pi from the math package. Or if you really just want to say pi, your import should be
from math import pi

5

u/Eye_Of_Forrest Jun 15 '21

from math import pi

or

print(math.pi)

2

u/[deleted] Jun 15 '21

I’d do the former and not import math entirely as it’s pretty big

1

u/dcolecpa Jun 14 '21

Looks like you imported the math module okay

1

u/OtherAd9058 Jun 15 '21 edited Jun 15 '21

Doesn’t the import have to be distinctively orange to be active. Like how when you use the print function it turn blue Edit Never-mind I see it now

3

u/demdillypickles Jun 15 '21

Nope, it will stay uncolored if properly used.

2

u/DeathSSStar Jun 15 '21

From math import *

3

u/[deleted] Jun 15 '21

Please, don't

2

u/DeathSSStar Jun 15 '21

he wants the math, i give the whole math