Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Functions and Looping Returning Values

Alexis Suberville
Alexis Suberville
1,455 Points

What's the logic of having to import "math" before being able to use the functions? Are they not readily available?

If we don't import math, it looks like it becomes an undefined value.. but what is the benefit of having that vs having all of these functions 'pre-loaded'? Thanks!

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi, Alexis Suberville! The math library is part of the base Python language, yes. But it is abstracted out into its own library. To use any of the libraries you need to import them. Math is just one of those. There are many many more including libraries to read CSV files, do basic statistics, handle data persistence, data compression and more. Your simple script would be incredibly bloated with unnecessary overhead if every library were loaded.

Here is a list of built-in libraries

Hope this helps! :sparkles:

Alexis Suberville
Alexis Suberville
1,455 Points

Makes a lot of sense, thank you!

thank you a lot Jenifer it really helps