Python for Data Science: Chapter 2: Functions and Files

Python Importing Libraries

There are many variables and functions present in the module. We can use them by using the import statement.

 Importing Libraries

• There are many variables and functions present in the module. We can use them by using the import statement.

•  When we simply use import statement, then we can use any variable or function present within that modulę.

• When we use from...import statement, then we can use only selected variables or functions present within that module.

 

For example

from math import sqrt

print("Square root (25)= ",sqrt(25))

Output

Square root (25)= 5.0

•  If we want to use some different name for the standard function present in the module, then we can use as keyword. Following code illustrates this ‒

 

moduleProg1.py

from math import sqrt as my_sq_root

print("Square root(25)= ",my_sq_root(25))

Output

Square root(25)= 5.0

>>> 

 

Python for Data Science: Chapter 2: Functions and Files : Tag: Computer Programming, Python, Data Science : - Python Importing Libraries


Python for Data Science: Chapter 2: Functions and Files



Under Subject


Python for Data Science

AD25201 2nd Semester AIDS Dept, 4th Semester CSE, CSE(CY) Departments | 2025 Regulation | 2nd, 4th Semester 2025 Regulation


Foundations of Data Science using Python

IT25201 2nd Semester IT Dept | 2025 Regulation | 2nd Semester 2025 Regulation



Related Subjects


English Essentials II

EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation



Linear Algebra

MA25C02 2nd Semester | 2025 Regulation


Applied Physics (CSIE) II

PH25C03 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Digital Principles and Computer Organization

CS25C06 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electrical and Electronics Engineering

EE25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Python for Data Science

AD25201 2nd Semester AIDS Dept, 4th Semester CSE, CSE(CY) Departments | 2025 Regulation | 2nd, 4th Semester 2025 Regulation


Re-Engineering for Innovation

ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Python for Data Science - Laboratory

AD25201 2nd Semester AIDS Dept | 2025 Regulation | 2nd Semester 2025 Regulation