Skip to content

pranavsinghal77/python-assignment-part3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Part 3 — File I/O, APIs & Exception Handling

Name: Pranav Singhal Student ID: BITSoM_BA_2511208

Overview

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.

Files

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)

Tasks Covered

  • 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_safe with finally, fetch_safe wrapper, input validation loop)
  • Task 4 — Error logging (log_error with datetime.now(), ConnectionError & HTTP 404 scenarios)

How to Run

  1. Install the requests library if not already installed: pip install requests
  2. Open part3_api_files.ipynb in Jupyter Notebook or JupyterLab
  3. Run Kernel → Restart & Run All
  4. Note: Some cells contain input() prompts — enter a keyword (e.g. phone) and a product ID (e.g. 1) when prompted
  5. python_notes.txt and error_log.txt will be regenerated automatically when cells are run

Requirements

  • Python 3.8+
  • requests library (pip install requests)
  • Internet connection (for DummyJSON API calls)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors