Python Standard Library
The library that comes with the language is a set of modules you import without installing them. math, json, and csv are in that set. bakery is not. You wrote that folder yourself. You do not download math, and you do not copy it into your own folder. The import line is the whole step. Installing is a later page. Here the module is already on the machine, because the language brought it.
import math
print(math.floor(2.9))
The screen shows 2. floor drops the fraction. 2.9 does not become 3, and it does not stay 2.9. The result is the integer 2, not 2.0. sqrt is not in this program. math was already importable. floor is another name inside that same module. print writes 2 with no decimal point. If the result were 2.0, the point would be on the screen.
📊 Where the module comes from
| Module | Where it comes from |
|---|---|
| math | the library that comes with the language |
| json | the same library |
| csv | the same library |
| bakery | a folder you write yourself |
import bakery stops when that folder is not on the machine. The name of the stop is ModuleNotFoundError. That line is not in this program. None is not written in its place, and the program does not go on. math does not stop that way. math is already in the library, so the import finds it.
The next page is dates and times. This page only separates modules that arrive with the language from a folder you write, and it shows floor dropping a fraction.
Already there, or written by you
math.floor(2.9) shows 2. math, json, and csv arrive with the language. bakery does not. A missing folder stops as ModuleNotFoundError. The next page is dates and times.
🧠 Test Your Knowledge
Test Your Knowledge
Challenge yourself with this interactive quiz and see how well you understand the topic
📝 Instructions
- Read each question carefully
- Select the best answer for each question
- You can retake the quiz as many times as you want
- Your progress will be shown at the top