File size: 490 Bytes
a3b917a
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)