# Pygorithm module in Python

Hello Learners, today we are going to learn about the Pygorithm module in Python in brief. with this small tutorial, we will try to give you an overview of the Pygorithm module.

This is a module for beginners who want to learn Python. This module is written in python itself and it is for learning purposes. The Pygorithm module provides the implementation of all the frequently used algorithms along with their time complexities and analysis. You don’t need to give load on your browser searching for it instead, you can just import the pygorithm module and get going with the algorithm.

## How to Use Pygorithm Module

You can make use the most of this module and this will be very helpful if you are a beginner. So, the first step is to download and install the module. You can use the given command on command prompt to install it:

`pip3 install pygorithm`

after this, you can see the output like this on your cmd, pygorithm module is installed and ready to use.

There are various different algorithms, you can import anyone out of them that you need. I have listed some classes below that comes under pygorithm module:

• Strings
• Sorting
• Searching
• Math
• Data Structures
• Greedy Algorithms
• Dynamic Programming Algorithms
• Path finding Algorithms
• Geometry etc.

Now let’s see some examples for better understanding.

Example 1 :

```from pygorithm.strings import palindrome
print(palindrome.get_code())
palindrome.is_palindrome("malayalam")
palindrome.is_palindrome("hello")```

OUTPUT:

```def is_palindrome(string):
"""Checks the string for palindrome

:param string: string to check
:return: true if string is a palindrome false if not
"""
if string == string[::-1]:
return True
return False```
• The get_code() method is used to print the complete code for the algorithm that you want to use.
• whereas is_palindrome methods accepts a string as parameter and checks whether it is palindrome or not.

Let’s take another example of Shell sort. Example 2 :

```from pygorithm.sorting import shell_sort
l = [3,2,8,5,6,20,1]
shell_sort.sort(l)
shell_sort.time_complexities()```

OUTPUT:

```[1, 2, 3, 5, 6, 8, 20]
'Best Case: O(nlogn), Average Case: O(depends on gap sequence), Worst Case: O(n ^ 2)'```
• The time_complexities() method gives you the best case, average case and the worst-case complexity of the given algorithm.
• whereas the sort method is used to sort the given list as a parameter.

As you have seen pygorithm module doesn’t just help in ease of coding but also helps and inspires the new coders to learn more and more, So there are plenty of algorithms it’s your turn to do it on your own and try them out.