Generic Import on lesson 18


#1

In lesson 18. Modules

if I start by using

from math import sqrt
print sqrt(13689)

the code, as expected, works, but if I change it to

import math
print sqrt(13689)

it also works, but I think it shouldn't because in earlier lessons I was teached that when using the generic import I had to use "math.sqrt" and not just "sqrt". Is this not a bug from Codecademy on this lesson?


#2

yes,i test it with my compiler and when use :

import math
print(sqrt(13689))

say its wrong and sqrt not define
the True way is :

import math
print(math.sqrt(13689))

or

from math import sqrt
print(sqrt(25))


#3

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