← All lessons

from … import: take a name

Sign in · Sign up

Lesson 7.1

from … import … takes one particular name from a module — and after that the module name is no longer needed:

from random import randint

# The bounds in this task come from the check — put them into the call.
print(randint)                 # this is a function; calling it is your part of the task

Notice the order: first from, then the module, then import, then the name. import randint from random is an error. After such a line random.randint(...) no longer works: the name random was not imported.

The check sets low, high and the answer answer: its randint returns answer instead of a random number. Take only randint from random and print a number from low to high — the result will match answer.

Hint

from random import randint imports one function by name.

After that random.randint(...) is no longer available — call randint(low, high). The bounds are the ones from the task.