Skip to Main Content

Introduction to Python

This guide was designed to supplement the INTRODUCTION TO PYTHON virtual workshop. If you have concerns or suggestions for this guide, feel free to reach out to scholarlyengagement@tulane.edu.

Introduction to Libraries: Math

Libraries are code stores that allow you to perform functions and other operations. Functions can be called from a library by referencing the library in your code. The code below demonstrates the importing process for libraries that are already downloaded to your system. To learn more about downloading libraries in the Jupyter Notebook environment, visit the following link: https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/

In this section, you will learn how to:

  • Importing and accessing the Math library

Math Library Code

Copy the following code on the left in your IDE to execute the process shown in the image on the right.


Importing a Library | import library as nickname

import math as mt                                            

 

 


Using a Function from an Imported Library | nickname.function(argument1, argument2, ...)

mt.sqrt(25)

mt.pi

mt.fsum((2,3,4,5,6))

mt.trunc(35.555)

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.