Computer Science, asked by Absbdnx, 6 months ago

WAP to calculate electricity bill
Units
Rate
Upto 100
2/unit
Upto 200
3/unit
Upto 500
5/ unit
After
7/unit

Answers

Answered by AnshumanRai9910
0

Answer:

Check explaination

Explanation:

# Python3 implementation to calculate the  

# electricity bill  

 

# Function to calculate the  

# electricity bill  

def calculateBill(units):  

 

   # Condition to find the charges  

   # bar in which the units consumed  

   # is fall  

   if (units <= 100):  

       

       return units * 10;  

     

   elif (units <= 200):  

     

       return ((100 * 10) +  

               (units - 100) * 15);  

     

   elif (units <= 300):  

       

       return ((100 * 10) +  

               (100 * 15) +  

               (units - 200) * 20);  

     

   elif (units > 300):  

     

       return ((100 * 10) +  

               (100 * 15) +  

               (100 * 20) +  

               (units - 300) * 25);  

     

   return 0

Similar questions