Did you know that Python is an open source language? And because of being open source, large amounts of people and community are contributing to its source code every single day, which is why we have so many additional and external modules and frameworks of Python.
These modules are used in Python to build vast variety of amazing applications and projects. Currently, Python is being used in almost every tech domain be it Web development, Machine Learning and Artificial Intelligence, Game development, Data Science, building GUI applications and so on.
If you try to research about the types of modules that can be used in python, you will find that the list seems to be endless as there is an external module for almost everything in Python.
After doing some research and surfing, I have come across a few most important libraries that you should know as a developer.
In this blog post, I am going to discuss Top 15 most important Python modules everyone should know/learn.
I have categorized the article into different development fields and explained the most useful python libraries in that particular domain. These are:
- Web Development
- Game development
- Machine learning and Artificial intelligence
- Data Science
- GUI applications
Web development
In web development, python is mainly used to build server side web applications and it is mostly used in combination with JavaScript. Every web developer must have heard the name or would have worked in the python frameworks like Django and Flask. However, Let's discuss about the python libraries that you can use in web development.
Requests module
- The requests module helps to send HTTP requests using python.
- You can also customize your requests’ headers and data, using the query string and message body. For example,
import requests
x = requests.get('https://hashnode.com/')
print(x.text)
Beautiful Soup
There are mainly two ways of extracting data from websites:
- Use the API of the website
- Web scraping (Web scraping is a technique to extract useful data of a website by accessing the HTML of the website.
And this python library Beautiful Soup is used for web scraping purposes i.e. it is used for pulling out data from HTML and XML files.
Selenium
- Selenium is an open source web based automation tool used for automating and controlling web browsers.
- Python can also be used in automation testing. Automation testing is a process of converting any manual test case into the test scripts using automation tools such as Selenium.
Here is an illustration for Webdriver:
# Python program to demonstrate Webdriver For Firefox
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://mbasic.facebook.com")
Game development
Although, Python is not more popular in game development as it is in other domains(Reason: Python is interpreted instead of being compiled which takes a longer time to execute). However, if you want to create small scale games, then python is the excellent choice for you. The most important python library for game development is
PyGame
- Pygame is a cross-platform set of Python modules which is used to create video games. It consists of computer graphics and sound libraries designed to be used with the Python programming language.
- Pygame uses the Simple DirectMedia Layer (SDL) library.
- Applications using PyGame can run on Android phones and tablets as well with the use of PyGame Subset for Android.
Here is a small illustration of a game developed in Python and named as "Car Race"
import pygame
pygame.init()
gameDisplay = pygame.display.set_mode((800,600))
pygame.display.set_caption('Car Race')
Apart from PyGame, Python uses frameworks like Twisted for online gaming and game development.
Machine Learning and Artificial Intelligence
As we all know, Python is one of the most important component of Machine learning and Artificial intelligence and is widely used in almost all applications of AI. But, there are a few libraries that make python even more powerful and useful for ML and AI applications. Let's discuss about them one bu one.
TensorFlow
- TensorFlow is a free and open-source software library for dataflow and differentiable programming across a range of tasks.
- It is maintained and supported by google. It is used for both research and production at Google.
- It supports machine learning and deep learning and the flexible numerical computation core is used across many other scientific domains.
Keras
- Keras is an open-source neural-network library written in Python. It is capable of running on top of TensorFlow.
- Keras is an API designed for human beings, not machines. Its application lies in implementing higher level APIs for TensorFlow.
- It was developed to make implementing deep learning models as fast and easy as possible for research and development.
PyTorch
- PyTorch is also an open source machine learning library used for developing and training neural network based deep learning models. It was primarily developed by Facebook's AI research group.
- PyTorch works faster than Keras and hence is more popular among developers.
Data Science
Data science is a branch of computer science where we study how to store, use and analyze data for deriving information from it. Python is one of the valuable skills needed for a data science career. Data scientists across the world use python for a large variety of applications. Here are some of the most important libraries used by Data Scientists.
NumPy
- NumPy is mainly used for mathematical operations such as computation of arrays, linear algebra, matrices, fourier transform, etc.
- It's high speed coupled with easy to use functions make it a favourite among Data Science practitioners.
The following example shows how we can randomly sample data using numpy:
# importing numpy
import numpy as np
# output array
outArr = np.random.randint(low = 0, high = 3, size = 5)
print ("Output 1D Array filled with random integers : ", outArr)
Pandas
- Pandas is mainly used for working in dataframes. It is mainly used for data manipulation.
- It is built on the Numpy package and its key data structure is called the DataFrame. DataFrames allow you to store and manipulate tabular data in rows of observations and columns of variables.
The following example shows how to create dataframes:
# importing pandas library
import pandas as pd
# making data frame
data = pd.read_csv("FILE_NAME.csv")
# storing in new variable
data_top = data.head()
# displaying
data_top
Matplotlib
- Matplotlib is used as a data visualisation tool in Data Science. It is a multi-platform data visualization library built on NumPy arrays.
- Matplotlib consists of several plots like line, bar, scatter, histogram etc. Plots helps to understand trends, patterns, and to make correlations.
OpenCV
-OpenCV is like a magical tool in python. It is a huge open-source library for computer vision, machine learning, and image processing.
- It can process images and videos to identify objects, faces, or even the handwriting of a human.
GUI Applications
GUI stands for graphical user interface. Python offers multiple options for developing GUI. There are many libraries of python used in GUI programming, however, tkinter is the most common and popular among all.
tkinter
- It is a standard Python interface to the Tk GUI toolkit shipped with Python.
- Python with tkinter is the fastest and easiest way to create the GUI applications. Creating a GUI using tkinter is easy and gives the best desired outputs.
Turtle
- Turtle is a pre-installed Python library that enables users to create pictures and shapes by providing them with a virtual canvas.
- Turtle is an awesome tool that can be used for designing graphics and various beautiful shapes of all forms and sizes in python.
The following kinds of graphic designs can be created using turtle:
PyQT
- It is a Python interface for Qt, one of the most powerful, and popular cross-platform GUI library. PyQt is a blend of Python programming language and the Qt library.(Qt is set of cross-platform C++ libraries that implement high-level APIs for accessing many aspects of modern desktop and mobile systems. )
- PyQt5 can also be embedded in C++ based applications to allow users to configure or enhance the functionality of their applications.
Kivy
- Kivy is not a library but a Python framework.
- Kivy is a great tool for developing Android Apps. The best advantage of using kivy is that it is cross platform and the same project can be used to publish apps on iOS , Android , windows, macOS or any other operating system.
So, this was my list of useful python libraries. However, If you want to check out all the python libraries along with there applications, it is available on the Official site of Python.