49%
Instructions
Importing Modules 📦
Modules are files containing Python code that you can include in your project.
How to Import
import math
print(math.sqrt(16)) # 4.0
Importing specific parts
from math import pi
print(pi)
Using an Alias
import datetime as dt
print(dt.datetime.now())
💡 Did You Know? Modules allow you to split your code into many files, making it much easier to manage large projects.
Your Turn!
Import the random module. Use random.randint(1, 1) to generate a random number (it will always be 1). Print the result.
Help
ModulesExercise 39/77 • 30 XP
❴❵ script.py
Terminal