Top Related Projects
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
- 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
- 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
- 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:
-
Clone the repository:
git clone https://github.com/OmkarPathak/Python-Programs.git
-
Navigate to the desired program or algorithm directory.
-
Run the Python script:
python script_name.py
-
Modify and experiment with the code to learn and understand the concepts better.
Competitor Comparisons
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 designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Python-Programs
This is my collection of Python Programs.
For python tutorials, visit my website:
http://www.omkarpathak.in
Omkar Pathak,
Pune, Maharashtra, India.
Sorting Algorithms
- Selection Sort
- Bubble Sort
- Insertion Sort
- Merge Sort
- Quick Sort
- Counting Sort
- Bucket Sort
- Shell Sort
- Heap Sort
Searching Algorithms
Data Structures
Simple Games in Python
OOP
- Class Definition
- Instance Methods
- Instance Attributes
- Constructor (init)
- Inheritance
- Multiple Inheritance
- Private Variables
- Magic Methods
Trees
- Simple Binary Tree
- Binary Search Tree
- Depth First Traversal
- Breadth First Traversal
- Count Leaf Nodes
- Building Tree from Preorder and Inorder
- Print all the paths to leaf nodes
Graphs
- Graph
- Breadth First Search
- Depth First Search
- Detect Cycle in Directed Graph
- Detect Cycle in Undirected Graph
- Topological Sort
- Prim's Algorithm
Scripts
- Create Multiple Folders
- Count files
- Get File sizes
- Find if a file exists
- Folder organization
- Get Dictionary Meaning
- Sending Mail
- Counting Number of Words
- Birthday Reminder
- Script to download tutorial from tutorials point
- Script to check email in your terminal
- Script to find devices connected to Network
- Script to create metadata for a file
Python Concepts
- Variable Scope
- List Methods
- Closures
- More on Closures
- Decorators
- More on Decorators
- List Comprehensions
- Python Generators
Numpy
- Introduction and Basics of Numpy
- Numpy Data Types
- Numpy Array Attributes
- Generate Numpy array from various numerical ranges
- Numpy Array Manipulation operations
- Numpy String Functions
- Numpy Mathematical Functions
- Numpy Arithmetical Operations
Mini Projects
- Address Book With Add, Modify, Search.
- Simple Python Keylogger
Random Python Programs
- OS Module
- Logging
- JSON Module
- Argument Parser
- CSV Module
- Pickle Module
- Hashing Finding a Hash of a file.
- Cipher Text Encrypting and decrypting a message based on some key specified by the user.
- Factorial Finding the factorial of a number using recursion.
- Fibonacci Finding the fibonaaci series upto a certain number using recursion.
- Count Characters Count the number(frequency) of Characters in a given sentence or string.
- Pattern Implementation of various Patterns using Python.
- LCM Finding the LCM using Python.
- Palindrome Check whether the given string is palindrome or not.
- Isogram Word or Phrase without a repeating letter
- Pangram A sentence containing every letter of the alphabet
- Anagram Rearranging of words or phrase to produce a new word or phrase, using all the original letters exactly once
- Perfect Number Check if the given number is a perfect number
- Pascal Triangle Implementation of Pascal Triangle
- Sieve Of Erathosthenes One of the efficient algorithms to find all the prime numbers upto n, where n can be upto 10 million
- Reverse the words Reversing the order of WORDS in a sentence
- Python Progress bar A simple progress bar helpful for showing the progress of a download
- Python unittest Module A Python module for writing test cases
- Python Lambda Function An example of Python Lambda function
- Python Encryption example using RSA Algorithm Encryption/ Decryption using RSA Algorithm
- Python ftplib A simple Python FTP file transfer example
- Python Django Project (beginner) A simple Django Project with two endpoints to show IFSC and bank details
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 :)
PayPal | |
---|---|
â¹ (INR) |
Top Related Projects
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
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot