0
0
Pythonprogramming~10 mins

Import statement behavior in Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the math module.

Python
import [1]
Drag options to blanks, or click blank then click option'
Aos
Bmath
Csys
Drandom
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong module name.
Forgetting to write the module name after import.
2fill in blank
medium

Complete the code to import only the sqrt function from the math module.

Python
from math import [1]
Drag options to blanks, or click blank then click option'
Acos
Bpi
Csin
Dsqrt
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the whole module instead of just the function.
Choosing a function other than sqrt.
3fill in blank
hard

Fix the error in the import statement to use an alias for the math module.

Python
import math as [1]
Drag options to blanks, or click blank then click option'
Am
Bmth
Cmaths
Dmat
Attempts:
3 left
💡 Hint
Common Mistakes
Using a long or confusing alias.
Using the original module name as alias.
4fill in blank
hard

Fill both blanks to import the randint function from random module with an alias.

Python
from random import [1] as [2]
Drag options to blanks, or click blank then click option'
Arandint
Brandom
Crint
Drand
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong function name.
Using an alias that is not a valid identifier.
5fill in blank
hard

Fill all three blanks to import the choice and shuffle functions from random module with aliases.

Python
from random import [1] as [2], [3] as shuffle
Drag options to blanks, or click blank then click option'
Achoice
Bpick
Csample
Dselect
Attempts:
3 left
💡 Hint
Common Mistakes
Using function names that do not exist in random module.
Using aliases that are not valid Python names.