1. Write a Python program that prompts the user to input their electricity consumption (in kWh) and calculate the total electricity bill based on the following tariff structure:

\begin{tabular}{|l|r|r|}
\hline
& Energy Charge (LKR/kWh) & Fixed Charge (LKR/month) \\
\hline
Consumption [tex]$0-60$[/tex] kWh / month & 10.00 & 150.00 \\
\hline
[tex]$0-30$[/tex] & 25.00 & 300.00 \\
\hline
[tex]$31-60$[/tex] & 32.00 & 4.00 \\
\hline
Consumption above [tex]$60$[/tex] kWh / month & 35.00 & 400.00 \\
\hline
[tex]$0-60$[/tex] & 50.00 & 1000.00 \\
\hline
[tex]$61-90$[/tex] & 50.00 & 1500.00 \\
\hline
[tex]$91-120$[/tex] & 75.00 & 2000.00 \\
\hline
[tex]$121-180$[/tex] & 75.00 & 2500.00 \\
\hline
[tex]$\ \textgreater \ 180$[/tex] & 100.00 & 3000.00 \\
\hline
\end{tabular}



Answer :

To solve the problem of calculating the total electricity bill based on the given consumption, we need to carefully analyze the tariff structure and develop a program that computes the bill according to the specified rates.

### Step-by-Step Solution

1. Understand the Tariff Structure:
- For consumption between `0-60 kWh/month`, there are distinct tariffs for the first `30 kWh` and the next `30 kWh`.
- For consumption above `60 kWh/month`, different ranges are specified with their own rates.

2. Construct a Logic to Calculate the Bill:
- Based on the consumption input, identify the appropriate range and compute the energy charge (rate per kWh) and fixed charge (LKR/month) accordingly.

3. Prompt the User for Input:
- Use the `input()` function to get the user's electricity consumption.

4. Calculate the Bill:
- Use conditionals to check which slab the consumption falls into and compute the total bill by adding the energy charge and fixed charge.

Here is the detailed Python program to compute the electricity bill:

```python
def calculate_electricity_bill():
consumption = float(input("Enter your electricity consumption in kWh: "))

# Define the tariff structure
tariff_structure = [
{"range": (0, 30), "charge": 25.00, "fixed": 300.00},
{"range": (31, 60), "charge": 32.00, "fixed": 4.00},
{"range": (0, 60), "charge": 10.00, "fixed": 150.00},
{"range": (61, 90), "charge": 50.00, "fixed": 1500.00},
{"range": (91, 120), "charge": 75.00, "fixed": 2000.00},
{"range": (121, 180), "charge": 50.00, "fixed": 1000.00},
{"range": (181, float('inf')), "charge": 35.00, "fixed": 400.00}
]

# Initialize the charges
energy_charge = 0
fixed_charge = 0

# Find and compute the appropriate charges
if consumption <= 60:
if consumption <= 30:
energy_charge = consumption 25.00
fixed_charge = 300.00
else:
energy_charge = 30
25.00 + (consumption - 30) 32.00
fixed_charge = 300.00 + 4.00
else:
# Loop through each tariff and apply if range is matched
for tariff in tariff_structure:
if tariff["range"][0] <= consumption <= tariff["range"][1]:
energy_charge = consumption
tariff["charge"]
fixed_charge = tariff["fixed"]
break

total_bill = energy_charge + fixed_charge

print("Energy Charge (LKR):", energy_charge)
print("Fixed Charge (LKR):", fixed_charge)
print("Total Electricity Bill (LKR):", total_bill)

# Execute the function
calculate_electricity_bill()
```

### Explanation

1. Input: The program asks the user to input their electricity consumption in kWh.

2. Tariff Initialization: The tariff structure is defined in a list, where each dictionary contains the range of consumption, charge per kWh, and fixed monthly charge.

3. Bill Calculation:
- For consumption up to 60 kWh, the program computes charges for the respective slabs, with separate calculations for `0-30 kWh` and `31-60 kWh`.
- For consumption above 60 kWh, it iterates through the tariff structure to find the matching range and applies the corresponding rates.

4. Output: It prints out the energy charge, fixed charge, and total electricity bill.

This structured approach ensures that the program computes the electricity bill accurately based on the given tariff structure.