← All lessons

as: a short name

Sign in · Sign up

Lesson 7.2

as gives a module an alias — a short name:

import random as rnd

# The bounds in this task come from the check — put them into the call.
print(rnd)                     # the module under your name; the call is your part of the task

After as you must use the new name: random.randint(...) is no longer available. An alias is handy for long module names.

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

Hint

import random as rnd gives the module a second name.

You must use the new name: rnd.randint(low, high). The name random does not work after this kind of import.