Question

Energy consumption is measured in units of kilowatt hours (kWh). The more kWh a household use...

Energy consumption is measured in units of kilowatt hours (kWh). The more kWh a household use in a month, the higher the energy bill. A power company charges customers $0.12 per kWh for the first 500 kWh. After the first 500 kWh, the rate is $0.15 per kWh. Write a program to calculate energy charge. You must write and use the following two functions. (a) A main function: Ask the user to enter number of kWh used. Call the bill_calculator function and pass number of kWh used to it as an argument. (b) A bill_calculator function: This function has a parameter to receive number of kWh used. Calculate and display the energy charge.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

def bill_calculator(power):
    if power <= 500:
        return power * 0.12
    else:
        return (500 * 0.12) + ((power - 500) * 0.15)


def main():
    power = float(input('Enter kilowatt hours used: '))
    print('Please pay this amount: ' + str(bill_calculator(power)))

main()

Add a comment
Know the answer?
Add Answer to:
Energy consumption is measured in units of kilowatt hours (kWh). The more kWh a household use...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT