Python builtin libraries


#1

I am going through the primer on Python functions. On slide 7/19, it asks that you write the following

Ask Python to print sqrt(25) on line 3.

import math
print math.sqrt(25)

When I got to slide 11, I added some extra lines to the code shown
print
print doc
print name
print package

name had the value “builtin” which led me to the question “Did I really need to include the “import math” on slide 7?”. I commented it out and the code still ran properly. Is my assumption correct?


#2

Technically, yes. In your case the module may still be in memory. Try a refresh of that lesson and see if it still works without importing math.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.