-1

It is very annoying and makes code harder to read to have to write math. before every math function in python. Is there an easy way to make it so we can write just the function name without math. before them?

2 Answers2

1

You use from <module name> import * to import all functions or variables within a module. In order to import one specific item, use from <module name> import <to import> In your case, you would use from math import *.

llamaking136
  • 421
  • 5
  • 16
0

You can do this:

from math import *
ceil(10.2)
# 11

As Klaus D. suggested in the comments, this doesn't comply with the PEP 8 Style Guide, and I don't encourage you to use it. But I guess it can come in handy, especially if you 're using the interpreter.

Alex Metsai
  • 1,837
  • 5
  • 12
  • 24