Name: Pranav Singhal Student ID: BITSoM_BA_2511208
This assignment builds a Product Explorer & Error-Resilient Logger. It reads/writes files, fetches live data from the DummyJSON public API, and handles every failure scenario gracefully without crashing.
| File | Description |
|---|---|
part3_api_files.ipynb |
Main notebook with all 4 tasks |
python_notes.txt |
Generated by Task 1 — written and appended by the script |
error_log.txt |
Generated by Task 4 — timestamped error log (ConnectionError + HTTP 404 entries) |
- Task 1 — File I/O (write, append, read with
encoding="utf-8", keyword search) - Task 2 — REST API requests (
requests.get,timeout=5,raise_for_status(), filter & sort, POST request) - Task 3 — Exception handling (
safe_divide,read_file_safewithfinally,fetch_safewrapper, input validation loop) - Task 4 — Error logging (
log_errorwithdatetime.now(), ConnectionError & HTTP 404 scenarios)
- Install the
requestslibrary if not already installed:pip install requests - Open
part3_api_files.ipynbin Jupyter Notebook or JupyterLab - Run Kernel → Restart & Run All
- Note: Some cells contain
input()prompts — enter a keyword (e.g.phone) and a product ID (e.g.1) when prompted python_notes.txtanderror_log.txtwill be regenerated automatically when cells are run
- Python 3.8+
requestslibrary (pip install requests)- Internet connection (for DummyJSON API calls)