CoderHassan commited on
Commit
d57640e
·
verified ·
1 Parent(s): 30c178d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -14
app.py CHANGED
@@ -5,13 +5,7 @@ import scraper
5
  # URLs for different companies
6
  tariff_urls = {
7
  "IESCO": "https://iesco.com.pk/index.php/customer-services/tariff-guide",
8
- "FESCO": "https://fesco.com.pk/tariff",
9
- "HESCO": "http://www.hesco.gov.pk/htmls/tariffs.htm",
10
- "KE": "https://www.ke.com.pk/customer-services/tariff-structure/",
11
- "LESCO": "https://www.lesco.gov.pk/ElectricityTariffs",
12
- "PESCO": "https://pesconlinebill.pk/pesco-tariff/",
13
- "QESCO": "http://qesco.com.pk/Tariffs.aspx",
14
- "TESCO": "https://tesco.gov.pk/index.php/electricity-traiff"
15
  }
16
 
17
  def main():
@@ -36,7 +30,7 @@ def main():
36
  st.write(f"Monthly Bill for {appliance_name}: Rs. {monthly_bill}")
37
  st.write(f"Carbon Footprint: {carbon_footprint} kg CO2")
38
  else:
39
- st.write("Error fetching tariff data. Please try again.")
40
 
41
  def calculate_monthly_bill(tariff_data, load, daily_usage):
42
  daily_consumption = load * daily_usage # kWh per day
@@ -44,11 +38,8 @@ def calculate_monthly_bill(tariff_data, load, daily_usage):
44
 
45
  total_bill = 0
46
  for slab in tariff_data:
47
- # Default to infinity for upper limit if not defined
48
- upper_limit = slab['upper_limit'] if slab['upper_limit'] != float('inf') else monthly_consumption
49
-
50
  if monthly_consumption > slab['lower_limit']:
51
- consumption_in_slab = min(monthly_consumption, upper_limit) - slab['lower_limit']
52
  total_bill += consumption_in_slab * slab['rate']
53
 
54
  return round(total_bill, 2)
@@ -57,8 +48,7 @@ def calculate_carbon_footprint(load, daily_usage):
57
  daily_consumption = load * daily_usage # kWh per day
58
  monthly_consumption = daily_consumption * 30 # kWh per month
59
 
60
- # Assuming 0.92 kg CO2 per kWh
61
- emissions_factor = 0.92
62
  carbon_footprint = monthly_consumption * emissions_factor
63
  return round(carbon_footprint, 2)
64
 
 
5
  # URLs for different companies
6
  tariff_urls = {
7
  "IESCO": "https://iesco.com.pk/index.php/customer-services/tariff-guide",
8
+ # Add other companies as needed
 
 
 
 
 
 
9
  }
10
 
11
  def main():
 
30
  st.write(f"Monthly Bill for {appliance_name}: Rs. {monthly_bill}")
31
  st.write(f"Carbon Footprint: {carbon_footprint} kg CO2")
32
  else:
33
+ st.error("Error fetching tariff data. Please try again.")
34
 
35
  def calculate_monthly_bill(tariff_data, load, daily_usage):
36
  daily_consumption = load * daily_usage # kWh per day
 
38
 
39
  total_bill = 0
40
  for slab in tariff_data:
 
 
 
41
  if monthly_consumption > slab['lower_limit']:
42
+ consumption_in_slab = min(monthly_consumption, slab['upper_limit']) - slab['lower_limit']
43
  total_bill += consumption_in_slab * slab['rate']
44
 
45
  return round(total_bill, 2)
 
48
  daily_consumption = load * daily_usage # kWh per day
49
  monthly_consumption = daily_consumption * 30 # kWh per month
50
 
51
+ emissions_factor = 0.92 # kg CO2 per kWh
 
52
  carbon_footprint = monthly_consumption * emissions_factor
53
  return round(carbon_footprint, 2)
54