Write a function to calculate and return electricity bill. Units used are given. Price per unit is fixed and is increased after 750 units.


Topic: Write a function to calculate and return electricity bill. Units used are given. Price per unit is fixed and is increased after 750 units.

Solution

def calc_elect_bill(units):
    if units > 0:
        if units <= 750:
            return 5*units
        else:
            return 5*(750) + 7*(units-750)
    else:
        return -1



List all Python Programs