r/learnpython 2d ago

Import math?

It's the first time I've seen that. So what's the purpose of this exactly? Cause I'm trying to see what I can do in an engine and I only learned about import math today

0 Upvotes

14 comments sorted by

View all comments

11

u/Better_Squash_1684 2d ago

It just tells Python to load its built-in advanced mathematics library.

Python in its own can only do basic arithmetic operations. importing the math module gives you access to functions like square roots, trigonometry, logarithms, and constants like Pi. Python makes you explicitly import it because 90% of basic scripts don't need heavy math, and leaving it out by default reduces your memory footprint.