Spaces:
Sleeping
Sleeping
| import requests | |
| def fetch_tariff_data(): | |
| """Fetch tariff data from the WAPDA website.""" | |
| # Example URL, replace with actual | |
| url = "https://example-wapda-tariff.com/api" | |
| response = requests.get(url) | |
| return response.json() | |
| def calculate_bill(load, usage_hours, tariff_data): | |
| """Calculate the monthly electricity bill.""" | |
| total_units = (load / 1000) * usage_hours * 30 # kWh | |
| rate = tariff_data.get("rate_per_unit", 0) | |
| return round(total_units * rate, 2) | |