An open API service indexing awesome lists of open source software.

https://github.com/vinit-devops/python-practice-exercises

Python exercises for practicing core concepts, improving coding skills, and preparing for technical interviews.
https://github.com/vinit-devops/python-practice-exercises

learn-to-code learning-by-doing practice-programming python

Last synced: 8 days ago
JSON representation

Python exercises for practicing core concepts, improving coding skills, and preparing for technical interviews.

Awesome Lists containing this project

README

          

# Python Practice Exercises

A comprehensive collection of Python programming exercises organized into Jupyter notebooks for practicing core concepts, improving coding skills, and preparing for technical interviews.

## 📚 Overview

This repository contains **398 carefully curated Python exercises** covering fundamental programming concepts, NumPy operations, and data structures & algorithms. Each exercise includes:

- Clear problem statement with examples
- Input/output examples for better understanding
- Complete solutions with code
- Hints where applicable

## 📁 Repository Structure

The repository is organized into three main Jupyter notebooks:

### 1. `basic python.ipynb` (148 Questions)
Comprehensive Python programming exercises covering:

- **Fundamentals**: Variables, data types, operators, input/output
- **Control Flow**: Conditional statements (if/else), loops (for/while)
- **Data Structures**: Lists, tuples, dictionaries, sets
- **Functions**: Function definition, recursion, lambda functions, generators
- **Object-Oriented Programming**: Classes, inheritance, encapsulation, polymorphism
- **File Operations**: Reading/writing files, CSV, JSON processing
- **Advanced Topics**:
- Regular expressions (regex)
- Exception handling (try/except)
- Modules and packages
- Web scraping (requests, BeautifulSoup)
- Database operations (SQLite)
- PDF processing (PyPDF2)
- GUI programming (tkinter)
- Scientific computing (NumPy, pandas, matplotlib)

### 2. `numpy.ipynb` (100 Questions)
NumPy-focused exercises covering:

- **Array Creation**: Various methods to create arrays
- **Array Manipulation**: Reshaping, slicing, concatenation, splitting
- **Mathematical Operations**: Element-wise operations, linear algebra
- **Random Sampling**: Random number generation, distributions
- **Sorting & Searching**: Finding elements, sorting arrays
- **Statistics**: Mean, median, standard deviation, percentiles
- **Set Operations**: Union, intersection, difference
- **Boolean Indexing**: Conditional selection
- **Broadcasting**: Array operations with different shapes

### 3. `dsa.ipynb` (150 Questions)
Data Structures and Algorithms problems including:

- **Arrays**: Two pointers, sliding window, subarray problems
- **Strings**: Pattern matching, palindromes, anagrams
- **Linked Lists**: Reversal, merging, cycle detection
- **Trees**: Binary trees, BST, traversal methods, tree construction
- **Graphs**: DFS, BFS, shortest path, topological sort
- **Dynamic Programming**: Memoization, tabulation, optimization problems
- **Backtracking**: Permutations, combinations, N-Queens
- **Heap/Priority Queue**: Kth largest, merge k sorted lists
- **Binary Search**: Search in sorted/rotated arrays
- **Tries**: Prefix trees, word search
- **Design Problems**: LRU Cache, data stream problems

## 🎯 How to Use

1. **Clone the repository**:
```bash
git clone
cd python-practice-exercises
```

2. **Open Jupyter Notebook**:
```bash
jupyter notebook
```

3. **Choose a notebook** based on what you want to practice:
- Start with `basic python.ipynb` for fundamentals
- Move to `numpy.ipynb` for numerical computing
- Practice `dsa.ipynb` for interview preparation

4. **Work through exercises**:
- Read each question carefully
- Try to solve it yourself first
- Review the solution if needed
- Experiment with the code

## 📝 Exercise Format

Each exercise follows this structure:

```markdown
## Question X

[Problem description with clear requirements]

**Example:**
```
Input: [example input]
Output: [example output]
Explanation: [brief explanation]
```

**Hints:** [if applicable]

# Solution X

[Complete working solution with comments]
```

## 🛠️ Requirements

- Python 3.7+
- Jupyter Notebook or JupyterLab
- Required packages (install as needed):
```bash
pip install numpy pandas matplotlib beautifulsoup4 requests PyPDF2
```

## 📊 Statistics

- **Total Questions**: 398
- Basic Python: 148 questions
- NumPy: 100 questions
- Data Structures & Algorithms: 150 questions

## 🎓 Learning Path

**For Beginners**:
1. Start with `basic python.ipynb` (Questions 1-50)
2. Focus on fundamentals: variables, conditionals, loops
3. Practice data structures: lists, dictionaries
4. Learn file I/O and basic modules

**For Intermediate Learners**:
1. Complete remaining `basic python.ipynb` questions
2. Explore OOP concepts
3. Work through `numpy.ipynb` for numerical computing
4. Practice with libraries: pandas, matplotlib

**For Advanced/Interview Prep**:
1. Focus on `dsa.ipynb` problems
2. Practice time/space complexity analysis
3. Review solutions and optimize code
4. Solve similar problems on LeetCode/HackerRank

## 💡 Tips

- **Don't just read** - Type out solutions yourself
- **Experiment** - Modify solutions and see what happens
- **Understand** - Make sure you understand why a solution works
- **Practice regularly** - Consistency is key to improvement
- **Solve without hints first** - Challenge yourself before looking at solutions

## 📄 License

See [LICENSE](LICENSE) file for details.

## 🤝 Contributing

Feel free to:
- Report issues or suggest improvements
- Add more exercises (following the existing format)
- Improve existing solutions
- Add more examples or explanations

## 📚 Additional Resources

- [Python Official Documentation](https://docs.python.org/3/)
- [NumPy Documentation](https://numpy.org/doc/)
- [LeetCode](https://leetcode.com/) - For additional DSA practice
- [HackerRank](https://www.hackerrank.com/) - For coding challenges

---

**Happy Coding! 🚀**