Skip to ContentGo to accessibility pageKeyboard shortcuts menu
OpenStax Logo

Learning objectives

By the end of this section you should be able to

  • Explain differences between the standard library and PyPI.
  • Search and for modules of interest.

Built-in modules

The Python Standard Library is a collection of built-in functions and modules that support common programming tasks. Ex: The math module provides functions like sqrt() and constants like pi. Python's official documentation includes a library reference and a module index for becoming familiar with the standard library.

For decades, Python has maintained a "batteries included" philosophy. This philosophy means that the standard library should come with everything most programmers need. In fact, the standard library includes over 200 built-in modules!

Module Description


General calendar-related functions.


Basic date and time types and functions.


Generate and process email messages.


Mathematical functions and constants.


Interact with the operating system.


Generate pseudo-random numbers.


Mathematical statistics functions.


System-specific parameters and functions.


Educational framework for simple graphics.


Read and write ZIP-format archive files.
Table 7.1 Example built-in modules in the standard library.

Concepts in Practice

Built-in modules

Use the library reference, module index, and documentation links above to answer the questions.

Which page provides a list of built-in modules sorted by category?
  1. library reference
  2. module index
  3. PEP 2
What is the value of calendar.SUNDAY?
  1. 1
  2. 6
  3. 7
Which built-in module enables the development of graphical user interfaces?
  1. tkinter
  2. turtle
  3. webbrowser

Third-party modules

The Python Package Index (PyPI), available at, is the official third-party software library for Python. The abbreviation "PyPI" is pronounced like pie pea eye (in contrast to PyPy, a different project).

PyPI allows anyone to develop and share modules with the Python community. Module authors include individuals, large companies, and non-profit organizations. PyPI helps programmers install modules and receive updates.

Most software available on PyPI is free and open source. PyPI is supported by the Python Software Foundation and is maintained by an independent group of developers.

Module Description


Convert and format dates, times, and timestamps.


Extract data from HTML and XML documents.


Interactive plots and applications in the browser.


Static, animated, and interactive visualizations.


Video editing, compositing, and processing.


Natural language toolkit for human languages.


Fundamental package for numerical computing.


Data analysis, time series, and statistics library.


Image processing for jpg, png, and other formats.


Full-featured testing tool and unit test framework.


Elegant HTTP library for connecting to web servers.


Simple, efficient tools for predictive data analysis.


Fundamental algorithms for scientific computing.


Crawl websites and scrape data from web pages.


End-to-end machine learning platform for everyone.
Table 7.2 Example third-party modules available from PyPI.

Concepts in Practice

Third-party modules

Use and the links in the table above to answer the questions.

Which modules can be used to edit pictures and videos?
  1. BeautifulSoup and Scrapy
  2. Bokeh and Matplotlib
  3. MoviePy and Pillow
Which third-party module is a replacement for the built-in datetime module?
  1. arrow
  2. calendar
  3. time
Search for the webcolors module on PyPI. What function provided by webcolors looks up the color name for a hex code?
  1. hex_to_name
  2. name_to_hex
  3. normalize_hex

Exploring further

Programming blogs often highlight PyPI modules to demonstrate the usefulness of Python. The following examples provide more background information about the modules listed above.

Try It

Happy birthday

Module documentation pages often include examples to help programmers become familiar with the module. For this exercise, refer to the following examples from the datetime module documentation:

Write a program that creates a date object representing your birthday. Then get a date object representing today's date (the date the program is run). Calculate the difference between the two dates, and output the results in the following format:

    Your birth date: 2005-03-14
    Today's date is: 2023-06-01

    You were born 6653 days ago
    (that is 574819200 seconds)

    You are about 18 years old

Try It

More exact age

The datetime module does not provide a built-in way to display a person's exact age. Ex: The following program calculates an exact age (in years and days) using floor division and modulo. The output is: You are 15 years and 4 days old.

    from datetime import date

    birth = date(2005, 3, 14)
    today = date(2020, 3, 14) # 15 years later
    delta = today - birth
    years = delta.days // 365
    days = delta.days % 365
    print("You are", years, "years and", days, "days old")

Notice how leap years are included in the calculation. February 29th occurs four times between birth and today. Therefore, the user is not only 15 years old, but 15 years and 4 days old.

Many commonly used modules from PyPI, including arrow, are installed in the Python shell at Open the Python shell and type the following lines:

    import arrow
    birth = arrow.get(2005, 3, 14)

Refer to the humanize() examples from the arrow module documentation. In the Python shell, figure out how to display the number of years and days since birth using one line of code. Then display the number of years, months, and days since birth. Finally, use the print() function to output the results in this format: You are 18 years 4 months and 7 days old.

As time permits, experiment with other functions provided by the arrow module.


This book may not be used in the training of large language models or otherwise be ingested into large language models or generative AI offerings without OpenStax's permission.

Want to cite, share, or modify this book? This book uses the Creative Commons Attribution License and you must attribute OpenStax.

Attribution information
  • If you are redistributing all or part of this book in a print format, then you must include on every physical page the following attribution:
    Access for free at
  • If you are redistributing all or part of this book in a digital format, then you must include on every digital page view the following attribution:
    Access for free at
Citation information

© Mar 15, 2024 OpenStax. Textbook content produced by OpenStax is licensed under a Creative Commons Attribution License . The OpenStax name, OpenStax logo, OpenStax book covers, OpenStax CNX name, and OpenStax CNX logo are not subject to the Creative Commons license and may not be reproduced without the prior and express written consent of Rice University.

This book utilizes the OpenStax Python Code Runner. The code runner is developed by Wiley and is All Rights Reserved.