RizwanSajad commited on
Commit
d167d9a
·
verified ·
1 Parent(s): b0e71c9

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +14 -0
utils.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+ def fetch_tariff_data():
4
+ """Fetch tariff data from the WAPDA website."""
5
+ # Example URL, replace with actual
6
+ url = "https://example-wapda-tariff.com/api"
7
+ response = requests.get(url)
8
+ return response.json()
9
+
10
+ def calculate_bill(load, usage_hours, tariff_data):
11
+ """Calculate the monthly electricity bill."""
12
+ total_units = (load / 1000) * usage_hours * 30 # kWh
13
+ rate = tariff_data.get("rate_per_unit", 0)
14
+ return round(total_units * rate, 2)