A comprehensive collection of Python programming assignments covering Object-Oriented Programming (OOP) concepts and HTTP client development.
This project contains 12 programming assignments designed to teach fundamental and advanced programming concepts:
- Q01: Basic OOP - Classes, attributes, and methods
- Q02: Encapsulation - Private attributes, getters, setters, and properties
- Q03: Inheritance - Class hierarchies and method overriding
- Q04: Polymorphism - Duck typing and polymorphic functions
- Q05: Advanced OOP - Composition, dunder methods, and class methods
- Q06: Basic GET requests
- Q07: GET requests with query parameters
- Q08: POST requests with JSON data
- Q09: PUT and DELETE operations
- Q10: HTTP status code classification
- Q11: Practical status handling with error management
- Q12: Complete CLI HTTP client application
- Python 3.7 or higher
- Internet connection (for HTTP assignments)
-
Clone or download the project
git clone <repository-url> cd college_assignment
-
Install dependencies
pip install -r requirements.txt
college_assignment/
├── src/
│ ├── q01_oop_book_basics.py
│ ├── q02_oop_encapsulation.py
│ ├── q03_oop_inheritance.py
│ ├── q04_oop_polymorphism.py
│ ├── q05_oop_all_in_one.py
│ ├── q06_requests_get.py
│ ├── q07_requests_get_params.py
│ ├── q08_requests_post.py
│ ├── q09_requests_put_delete.py
│ ├── q10_http_status_classifier.py
│ ├── q11_fetch_with_status_handling.py
│ └── q12_cli_http_client.py
├── tests/
│ ├── smoke_tests.py
│ └── simple_smoke_tests.py
├── requirements.txt
└── README.md
Each assignment can be run independently:
# OOP Assignments
python src/q01_oop_book_basics.py
python src/q02_oop_encapsulation.py
python src/q03_oop_inheritance.py
python src/q04_oop_polymorphism.py
python src/q05_oop_all_in_one.py
# HTTP Assignments
python src/q06_requests_get.py
python src/q07_requests_get_params.py
python src/q08_requests_post.py
python src/q09_requests_put_delete.py
python src/q10_http_status_classifier.py
python src/q11_fetch_with_status_handling.pyThe Q12 assignment provides a complete CLI tool:
# GET request
python src/q12_cli_http_client.py GET https://jsonplaceholder.typicode.com/posts/1
# POST request with JSON
python src/q12_cli_http_client.py POST https://jsonplaceholder.typicode.com/posts '{"title":"Test","body":"Content","userId":1}'
# PUT request
python src/q12_cli_http_client.py PUT https://jsonplaceholder.typicode.com/posts/1 '{"title":"Updated"}'
# DELETE request
python src/q12_cli_http_client.py DELETE https://jsonplaceholder.typicode.com/posts/1Run all assignments to ensure they execute without errors:
# Simple smoke test
python tests/simple_smoke_tests.py
# Detailed smoke test with reporting
python tests/smoke_tests.py=== Smoke Tests for College Assignment ===
Testing 12 files from: C:\...\college_assignment\src
--------------------------------------------------
Running q01_oop_book_basics.py ...
[PASS] Passed
...
SUMMARY: 12 passed, 0 failed
[PASS] All 12 files passed smoke tests!
- Encapsulation: Data hiding and controlled access
- Inheritance: Code reuse and hierarchical relationships
- Polymorphism: One interface, multiple implementations
- Composition: Building complex objects from simpler ones
- Dunder Methods: Python's special methods (
__init__,__str__, etc.) - Class Methods: Alternative constructors and factory patterns
- REST API Interaction: GET, POST, PUT, DELETE operations
- Request/Response Handling: Status codes, headers, JSON data
- Error Handling: Network timeouts, connection errors, HTTP errors
- Query Parameters: URL parameter construction and handling
- JSON Processing: Parsing and formatting JSON data
- CLI Development: Command-line interface design
- Progressive Learning: Each assignment builds on previous concepts
- Real-World Examples: Book management system with Indian pricing
- Practical Applications: CLI tools and API clients
- Error Handling: Comprehensive exception management
- Best Practices: Clean code, documentation, and validation
- Python 3.7+ Compatible: Modern Python features
- Minimal Dependencies: Only standard library + requests
- Cross-Platform: Works on Windows, macOS, and Linux
- Unicode Safe: Proper handling of international characters
- Well-Documented: Clear comments and docstrings
| Assignment | Topic | Key Concepts |
|---|---|---|
| Q01 | Basic OOP | Classes, attributes, methods |
| Q02 | Encapsulation | Private attributes, properties |
| Q03 | Inheritance | Subclasses, method overriding |
| Q04 | Polymorphism | Duck typing, polymorphic functions |
| Q05 | Advanced OOP | Composition, dunder methods |
| Q06 | HTTP GET | Basic API requests |
| Q07 | GET with Params | Query parameters |
| Q08 | HTTP POST | Creating resources |
| Q09 | PUT & DELETE | Updating and removing resources |
| Q10 | Status Codes | HTTP response classification |
| Q11 | Error Handling | Practical status management |
| Q12 | CLI Client | Complete HTTP client tool |
- Python Standard Library:
sys,json,pathlib,subprocess - External Library:
requests(for HTTP functionality)
All HTTP assignments use the JSONPlaceholder API:
- Base URL:
https://jsonplaceholder.typicode.com - Endpoints:
/posts,/comments,/posts/{id} - Methods: GET, POST, PUT, DELETE
- Run assignments in order - Each builds on previous concepts
- Read the code comments - They explain the implementation details
- Experiment with modifications - Try changing parameters and data
- Use the smoke tests - Validate your environment setup
- Check network connectivity - HTTP assignments require internet access
graph TD
A[Q01: Basic OOP] --> B[Q02: Encapsulation]
B --> C[Q03: Inheritance]
C --> D[Q04: Polymorphism]
D --> E[Q05: Advanced OOP]
E --> F[Q06: HTTP GET]
F --> G[Q07: GET with Params]
G --> H[Q08: HTTP POST]
H --> I[Q09: PUT & DELETE]
I --> J[Q10: Status Codes]
J --> K[Q11: Error Handling]
K --> L[Q12: CLI Client]