Python and Libraries
Python
Python is one of the interpreted high-level programming languages. It is a general-purpose programming language that helps develop code in multiple paradigms. Guido van Rossum designed Python, and PSF (Python Software Foundation) is responsible for various processes designed using Python. The initial release of Python was in 1991. Since then, the platform has gained global recognition by supporting various communities through its features.
Python supports multiple programming paradigms, including structured programming, object-oriented programming, and functional programming. Released under the Python Software Foundation license, Python has gained importance due to its language constructs and utilization of object-oriented concepts to support developers in constructing logical, standard, understandable, flexible, and large-scale projects.
Libraries
A Python library corresponds to a file or piece of code used for a common purpose and increases code reusability by being helpful in various relevant projects and operations. Developers can add Python libraries to programs for the sake of reusability. In Python, a library represents a collection of some modules. There can also be user-defined libraries in Python.
Standard Library of Python
The Python Standard Library consists of a group of exact syntax, semantics, and tokens of the Python language. Moreover, there are core Python distributions bundled with the standard library. The developers have written this library in C language. The library handles the I/O operations and various other essential modules.
Additionally, the Standard Library consists of around 200 core modules of Python. Also, there is a Python Package Index or PyPI repository in Python. This repository consists of a wide range of open-source Python packages, and the whole developer community contributes to the maintenance and supply of the libraries and packages in it.
Libraries in Python
Since Python supports a wide range of platforms and helps develop complex projects, there is a wide range of libraries available in Python to facilitate the developers. These libraries serve various purposes and help in achieving optimal results. Below are some of the essential libraries in Python.
1. NumPy
NumPy is one of the most popular libraries used in machine learning projects. It consists of advanced mathematical functions and an essential scientific computing package. It is the best option while working with arrays. The domain of using NumPy includes linear algebra, Fourier transform, and matrices. Moreover, Numpy provides 50 times faster array objects than the traditional Python lists. An example of using NumPy is below:
import numpy as np numbers=np.array([1,2,3,4]) numbers
2. TensorFlow
Python also uses the TensorFlow library in machine learning projects. Google developed this open-source library in collaboration with Brain Team. Almost every google application uses TensorFlow. It is a computational library that helps in developing algorithms to work with huge tensor operations. Moreover, the neural networks in Python can easily be implemented using TensorFlow. It is helpful in working with large data sets. Following is an example of using TensorFlow:
import numpy as np import tflearn from tflearn.datasets import titanic titanic.download_dataset('titanic_dataset.csv') from tflearn.data_utils import load_csv data, labels = load_csv('titanic_dataset.csv', target_column=0, categorical_labels=True, n_classes=2) def preprocess(passengers, columns_to_delete): for column_to_delete in sorted(columns_to_delete, reverse=True): [passenger.pop(column_to_delete) for passenger in passengers] for i in range(len(passengers)): passengers[i][1] = 1. if passengers[i][1] == 'female' else 0. return np.array(passengers, dtype=np.float32) to_ignore=[1, 6] data = preprocess(data, to_ignore)
3. Matplotlib
Matplotlib is helpful in data analysis and numerical plotting. This library is quite helpful in the field of data science. It is a comprehensive library used to create visualizations that are static, animated, or interactive. A simple example of matplotlib is drawing a line with data points.
import matplotlib.pyplot as plt import numpy as np xpoint_a=np.array([0,5]) ypoint_a=np.array([0,20]) plt.plot(xpoint_a, ypoint_a) plt.show()
There are numerous other vital libraries in Python, including Pandas, Requests, SQLAlchemy, Pyglet, Scrapy, PyGame, and Python.
Other useful articles:
- OOP in Python
- Python v2 vs Python v3
- Variables, Data Types, and Syntaxes in Python
- Operators, Booleans, and Tuples
- Loops and Statements in Python
- Python Functions and Modules
- Regular Expressions in Python
- Python Interfaces
- JSON Data and Python
- Pip and its Uses in Python
- File Handling in Python
- Searching and Sorting Algorithms in Python
- System Programming (Pipes &Threads etc.)
- Database Programming in Python
- Debugging with Assertion in Python
- Sockets in Python
- InterOp in Python
- Exception Handling in Python
- Environments in Python
- Foundation of Data Science
- Reinforcement Learning
- Python for AI
- Applied Text Mining in Python
- Python Iterations using Libraries
- NumPy vs SciPy
- Python Array Indexing and Slicing
- PyGame
- PyTorch
- Python & Libraries