5 Best Python Libraries For Fun

In this article we want to talk about 5 Best Python Libraries For Fun, Python is high level and interpreted programming language used for different type of tasks such as web development, data analysis, artificial intelligence and scientific computing. it is known for its simplicity, readability, and versatility. Python was first released in 1991 and has since become one of the most popular programming languages in the world.

 

 

 

5 Best Python Libraries For Fun

  1. Pygame – Game development library
  2. Matplotlib – Data visualization library
  3. Turtle – Easy-to-use graphics library
  4. PyAutoGUI – Automate GUI tasks library
  5. Pillow – a library for processing images and performing tasks such as cropping, resizing and adding filters.

 

 

What is Pygame ?

Pygame is free and open source Python library used for making video games. it provides modules for you to use for creating 2D graphics, playing sounds and music, handling user input, and other features that are commonly used in game development. Pygame is designed to be easy to use and it allows you quickly create games without having to deal with the lowlevel details of graphics and sound. to install Pygame, you can use the following command in your terminal or command prompt:

 

Also if you’re using Anaconda, you can use the following command in your Anaconda prompt:

Note: make sure you have the latest version of pip or conda installed.

 

 

This is basic example of Pygame to display a window with a red background:

This code will display a window with a red background and wait for the user to close it.

 

 

Run the complete code and this will be the result 

5 Best Python Libraries For Fun
5 Best Python Libraries For Fun

 

 

What is Matplotlib ?

Matplotlib is plotting library for the Python programming language. it provides functions for creating static, animated and interactive visualizations in 2D and 3D. Matplotlib is widely used for data visualization, exploration and analysis, and supports different graph types, including line plots, scatter plots, bar plots, error bars, histograms and many more. it is also compatible with other popular Python libraries such as NumPy, pandas and Seaborn, making it a powerful tool for data analysis and presentation. for  installing Matplotlib you can use the following command in your terminal or command prompt:

 

Also if you’re using Anaconda, you can use the following command in your Anaconda prompt:

Note: make sure you have the latest version of pip or conda installed.

 

 

This simple example of Matplotlib to plot simple line graph:

This code will display a window with a line graph of the x and y data, with labels and a title.

 

 

 

Run the complete code and this will be the result

5 Best Python Libraries For Fun
5 Best Python Libraries For Fun

 

 

 

What is Turtle ?

Turtle is Python library for creating graphics. It was originally part of the Python standard library but has since been moved to a separate library. Turtle provides simple way to draw shapes and graphics and it makes it great tool for learning the basics of computer graphics as well as for creating simple animations and games. with Turtle you can draw shapes, lines and patterns by controlling cursor called turtle on the screen. turtle can be moved and rotated, and you can change its pen properties, such as color and width to create more complex drawings. Turtle is already included in the standard library of Python, so you don’t need to install it separately. 

 

This is simple example of Turtle to draw a square:

This code will display a window with a blue square drawn by the turtle. The turtle starts at the center of the window and moves forward 100 units to draw the first side of the square. It then turns right 90 degrees to face the next side and repeats the process until all 4 sides have been drawn.

 

 

Run the complete code and this will be the result

5 Best Python Libraries For Fun
5 Best Python Libraries For Fun

 

 

 

What is PyAutoGUI ?

PyAutoGUI is Python library for automating GUI interactions. it allows you to automate mouse and keyboard actions, such as clicking buttons, typing text and moving the mouse. with PyAutoGUI you can write scripts to automate repetitive tasks or perform tests on graphical user interfaces. PyAutoGUI works on Windows, macOS and Linux and supports different types of GUI applications, including web browsers, text editors and game clients. it can be used for different purposes such as data scraping, testing and automation of desktop applications. to install PyAutoGUI, you can use the following command in your terminal or command prompt:

 

Also if you’re using Anaconda, you can use the following command in your Anaconda prompt:

 

 

This si basic example of PyAutoGUI to move the mouse to a specific location:

This code will move the mouse cursor to the location (100, 100) on the screen.

Note: Please use PyAutoGUI with caution, as it can interfere with your other actions and even cause harm to your system if not used properly. it is recommended to run PyAutoGUI scripts in virtual environment or on a secondary device.

 

 

What is Pillow ?

Pillow is library for the Python programming language that provides support for handling and manipulating images. it is fork of the Python Imaging Library (PIL) and adds many new features and improvements over its predecessor. with Pillow you can load, manipulate and save various image formats including JPEG, PNG and GIF. You can also perform tasks such as cropping, resizing, rotating and applying filters to images. Pillow is widely used in Python community for tasks such as image processing, computer vision, and web development. To install Pillow, you can use the following command in your terminal or command prompt:

 

Also if you’re using Anaconda, you can use the following command in your Anaconda prompt:

 

 

This is basic example of Pillow to load and display an image:

This code opens an image file named image.jpg and displays it using the default image viewer. you can replace image.jpg with the path to your own image.

Note: Pillow also provides many other functions for image processing such as resizing, cropping and applying filters. To learn more about the library, you can check the official documentation at https://pillow.readthedocs.io/en/stable/.

 

 

Learn More on Python

Leave a Comment