Convert Figma logo to code with AI

OmkarPathak logoPython-Programs

My collection of Python Programs

1,030
582
1,030
57

Top Related Projects

31,133

My Python Examples

Minimal examples of data structures and algorithms in Python

An opinionated list of awesome Python frameworks, libraries, software and resources.

120+ interactive Python coding interview challenges (algorithms and data structures). Includes Anki flashcards.

:computer: Data Structures and Algorithms in Python

Quick Overview

OmkarPathak/Python-Programs is a GitHub repository containing a collection of Python programs and algorithms. It serves as a resource for learning Python programming and understanding various algorithms and data structures. The repository covers a wide range of topics, from basic Python concepts to more advanced algorithms and machine learning implementations.

Pros

  • Comprehensive collection of Python programs and algorithms
  • Well-organized structure with clear categorization of topics
  • Includes implementations of popular data structures and algorithms
  • Provides practical examples for learning Python and computer science concepts

Cons

  • Some code examples may not follow the latest Python best practices
  • Limited documentation for some programs and algorithms
  • Inconsistent coding style across different programs
  • Some implementations may not be optimized for performance

Code Examples

  1. Binary Search implementation:
def binary_search(arr, low, high, x):
    if high >= low:
        mid = (high + low) // 2
        if arr[mid] == x:
            return mid
        elif arr[mid] > x:
            return binary_search(arr, low, mid - 1, x)
        else:
            return binary_search(arr, mid + 1, high, x)
    else:
        return -1
  1. Bubble Sort implementation:
def bubble_sort(arr):
    n = len(arr)
    for i in range(n):
        for j in range(0, n-i-1):
            if arr[j] > arr[j+1]:
                arr[j], arr[j+1] = arr[j+1], arr[j]
    return arr
  1. Simple Linear Regression implementation:
def linear_regression(X, Y):
    n = len(X)
    sum_x = sum(X)
    sum_y = sum(Y)
    sum_xy = sum([x*y for x, y in zip(X, Y)])
    sum_x_squared = sum([x**2 for x in X])
    
    m = (n * sum_xy - sum_x * sum_y) / (n * sum_x_squared - sum_x**2)
    b = (sum_y - m * sum_x) / n
    
    return m, b

Getting Started

To use the programs in this repository:

  1. Clone the repository:

    git clone https://github.com/OmkarPathak/Python-Programs.git
    
  2. Navigate to the desired program or algorithm directory.

  3. Run the Python script:

    python script_name.py
    
  4. Modify and experiment with the code to learn and understand the concepts better.

Competitor Comparisons

31,133

My Python Examples

Pros of Python

  • Larger collection of scripts and programs covering a wider range of topics
  • More contributors and community involvement
  • Better organization with subdirectories for different categories

Cons of Python

  • Less focus on educational explanations and comments within the code
  • Some scripts may be outdated or not follow current best practices
  • Inconsistent coding style across different contributors

Code Comparison

Python-Programs (Binary Search):

def binarySearch(arr, l, r, x):
    if r >= l:
        mid = l + (r - l) // 2
        if arr[mid] == x:
            return mid
        elif arr[mid] > x:
            return binarySearch(arr, l, mid-1, x)
        else:
            return binarySearch(arr, mid+1, r, x)
    return -1

Python (Binary Search):

def binary_search(arr, x):
    low = 0
    high = len(arr) - 1
    mid = 0
    while low <= high:
        mid = (high + low) // 2
        if arr[mid] < x:
            low = mid + 1
        elif arr[mid] > x:
            high = mid - 1
        else:
            return mid
    return -1

Both repositories offer valuable Python resources, but Python-Programs focuses more on educational content with explanations, while Python provides a broader range of scripts and programs. The code comparison shows different implementations of binary search, with Python-Programs using recursion and Python using iteration.

Minimal examples of data structures and algorithms in Python

Pros of algorithms

  • More comprehensive coverage of algorithms and data structures
  • Better organized with clear categorization (e.g., sorting, searching, graph)
  • Includes implementations in multiple languages (Python, JavaScript, C++)

Cons of algorithms

  • Less focus on beginner-friendly explanations and comments
  • Fewer practical examples and real-world applications
  • More complex directory structure, potentially harder to navigate

Code Comparison

Python-Programs (Binary Search):

def binary_search(arr, l, r, x):
    if r >= l:
        mid = l + (r - l) // 2
        if arr[mid] == x:
            return mid
        elif arr[mid] > x:
            return binary_search(arr, l, mid-1, x)
        else:
            return binary_search(arr, mid+1, r, x)
    return -1

algorithms (Binary Search):

def binary_search(array, target):
    lower = 0
    upper = len(array)
    while lower < upper:
        x = lower + (upper - lower) // 2
        val = array[x]
        if target == val:
            return x
        elif target > val:
            if lower == x:
                break
            lower = x
        elif target < val:
            upper = x
    return -1

An opinionated list of awesome Python frameworks, libraries, software and resources.

Pros of awesome-python

  • Comprehensive curated list of Python resources, libraries, and tools
  • Well-organized into categories for easy navigation
  • Regularly updated with community contributions

Cons of awesome-python

  • Lacks actual code examples or implementations
  • May be overwhelming for beginners due to the sheer volume of resources

Code comparison

Python-Programs provides actual code implementations, while awesome-python is a curated list without code. Here's an example from Python-Programs:

def binary_search(arr, l, r, x):
    if r >= l:
        mid = l + (r - l) // 2
        if arr[mid] == x:
            return mid
        elif arr[mid] > x:
            return binary_search(arr, l, mid-1, x)
        else:
            return binary_search(arr, mid+1, r, x)
    return -1

awesome-python would instead provide a link to a binary search library or resource, without showing the implementation.

Summary

Python-Programs offers practical code examples and implementations, making it ideal for learners and those seeking ready-to-use solutions. awesome-python serves as a comprehensive directory of Python resources, perfect for discovering new tools and libraries. The choice between them depends on whether you need actual code or a curated list of resources.

120+ interactive Python coding interview challenges (algorithms and data structures). Includes Anki flashcards.

Pros of interactive-coding-challenges

  • More comprehensive coverage of data structures and algorithms
  • Includes interactive Jupyter notebooks for hands-on learning
  • Provides test cases and solutions for each challenge

Cons of interactive-coding-challenges

  • Focuses primarily on coding interview preparation
  • May be overwhelming for beginners due to its depth and complexity
  • Less emphasis on practical, everyday Python programming tasks

Code Comparison

Python-Programs:

def binary_search(arr, x):
    low = 0
    high = len(arr) - 1
    while low <= high:
        mid = (low + high) // 2
        if arr[mid] == x:
            return mid

interactive-coding-challenges:

class BinarySearch(object):
    def search(self, data, target):
        if data is None or target is None:
            return None
        return self._search_recursive(data, target, 0, len(data) - 1)

    def _search_recursive(self, data, target, low, high):
        if low > high:
            return None

The interactive-coding-challenges repository provides a more structured and object-oriented approach to implementing algorithms, while Python-Programs offers a simpler, more straightforward implementation. The former is better suited for in-depth study and interview preparation, while the latter is more accessible for beginners and quick reference.

:computer: Data Structures and Algorithms in Python

Pros of Algorithms

  • Covers a wider range of algorithms and data structures
  • Implementations in multiple languages (Python, Java, C++)
  • More comprehensive documentation and explanations

Cons of Algorithms

  • Less focused on Python-specific implementations
  • Fewer practical examples and real-world applications
  • May be more challenging for beginners due to its breadth

Code Comparison

Python-Programs (Binary Search):

def binary_search(arr, l, r, x):
    if r >= l:
        mid = l + (r - l) // 2
        if arr[mid] == x:
            return mid
        elif arr[mid] > x:
            return binary_search(arr, l, mid-1, x)
        else:
            return binary_search(arr, mid+1, r, x)
    return -1

Algorithms (Binary Search in Python):

def binary_search(arr, x):
    low = 0
    high = len(arr) - 1
    while low <= high:
        mid = (low + high) // 2
        if arr[mid] == x:
            return mid
        elif arr[mid] < x:
            low = mid + 1
        else:
            high = mid - 1
    return -1

Both repositories offer valuable resources for learning algorithms and data structures. Python-Programs focuses specifically on Python implementations with practical examples, while Algorithms provides a broader range of implementations across multiple languages with more comprehensive coverage of algorithmic concepts.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Python-Programs

GitHub stars Python

This is my collection of Python Programs.
For python tutorials, visit my website:
http://www.omkarpathak.in

Omkar Pathak,
Pune, Maharashtra, India.

Sorting Algorithms

  1. Selection Sort
  2. Bubble Sort
  3. Insertion Sort
  4. Merge Sort
  5. Quick Sort
  6. Counting Sort
  7. Bucket Sort
  8. Shell Sort
  9. Heap Sort

Searching Algorithms

  1. Sequential Search
  2. Binary Search
  3. N-ary Search

Data Structures

  1. Array
  2. Singly Linked List
  3. Doubly Linked List
  4. Stack
  5. Queue
  6. Hash Table

Simple Games in Python

  1. Number Guessing Game
  2. Hangman
  3. Rock Paper Scissor
  4. Tic Tac Toe

OOP

  1. Class Definition
  2. Instance Methods
  3. Instance Attributes
  4. Constructor (init)
  5. Inheritance
  6. Multiple Inheritance
  7. Private Variables
  8. Magic Methods

Trees

  1. Simple Binary Tree
  2. Binary Search Tree
  3. Depth First Traversal
  4. Breadth First Traversal
  5. Count Leaf Nodes
  6. Building Tree from Preorder and Inorder
  7. Print all the paths to leaf nodes

Graphs

  1. Graph
  2. Breadth First Search
  3. Depth First Search
  4. Detect Cycle in Directed Graph
  5. Detect Cycle in Undirected Graph
  6. Topological Sort
  7. Prim's Algorithm

Scripts

  1. Create Multiple Folders
  2. Count files
  3. Get File sizes
  4. Find if a file exists
  5. Folder organization
  6. Get Dictionary Meaning
  7. Sending Mail
  8. Counting Number of Words
  9. Birthday Reminder
  10. Script to download tutorial from tutorials point
  11. Script to check email in your terminal
  12. Script to find devices connected to Network
  13. Script to create metadata for a file

Python Concepts

  1. Variable Scope
  2. List Methods
  3. Closures
  4. More on Closures
  5. Decorators
  6. More on Decorators
  7. List Comprehensions
  8. Python Generators

Numpy

  1. Introduction and Basics of Numpy
  2. Numpy Data Types
  3. Numpy Array Attributes
  4. Generate Numpy array from various numerical ranges
  5. Numpy Array Manipulation operations
  6. Numpy String Functions
  7. Numpy Mathematical Functions
  8. Numpy Arithmetical Operations

Mini Projects

Random Python Programs

Donation

If you have found my softwares to be of any use to you, do consider helping me pay my internet bills. This would encourage me to create many such softwares :)

PayPalDonate via PayPal!
₹ (INR)Donate via Instamojo