đĄ What You'll Learn
Modules are files with reusable code. Import them with import to use functions and variables from other files. Python has many built-in modules!
math - math functionsrandom - random numbersdatetime - date & timeos - operating system
modules.py
1import math
2print(math.sqrt(16)) # 4.0
3print(math.pi) # 3.14159...
đē Try math functions!
Click to calculate!
đ¯ Your Challenges
1Random Number
Use random.randint(1, 10) to get a random number
2Round Number
Use round() to round 3.7
3Absolute Value
Use abs() to get absolute value of -5
đ What You Learned
import module_nameloads a module- Use:
module.function() from module import funcimports specific items- Python has hundreds of built-in modules