Python includes a module named math:
import mathLine-by-line explanation
importtells Python to load a module.mathis the module name.- Its tools are now available through that name.
answer = math.sqrt(25)Line-by-line explanation
math.selects something from the module.sqrtcalculates a square root.answerstores5.0.
Tiny Practice
Import the random module.
Starter template
CHANGE_ME randomLine-by-line explanation
- The line needs Python’s import keyword.
- Random is the module name.
Hint
- The keyword begins with i.
- Do not use quotes.
- Use one space.
Show Solution
import randomLine-by-line explanation
- Import is the instruction.
- Random is the requested module.
- Its tools can now be accessed with
random..