Import
Domain: Programming Fundamentals
π― Motivation
Python has a huge ecosystem of pre-written code. Importing lets you use code others have written.
π Concrete Example
import random gives you random.randint(1, 6) to roll a die. from math import sqrt gives you sqrt(16) = 4.
π Analogy
Borrowing books from a library - instead of writing your own encyclopedia, you borrow one thatβs already written and use the parts you need.