Answer to Question #289752 in Python for Den

Question #289752

Calasiao water district charges its customers P10 per unit for the first ten units of water consumption, P15 per unit for the next five units, and P17 for the succeeding units. Write a program that inputs the previous meter reading and the present meter reading, then display the number of units consumed and the water bill.


1
Expert's answer
2022-01-23T10:14:22-0500
prev_meter=int(input("Enter the previous meter reading: "))
pre_meter=int(input("Enter the present meter reading: "))
def waterbill(prev_meter,pre_meter):
    consumed=pre_meter-prev_meter
    print("The number of units of water consumed is {}".format(consumed))
    if consumed<=10:
        water_bill=10*consumed
    elif 10<consumed<=15:
        water_bill=15*consumed
    else:
        water_bill=17*consumed
    print("The water bill is P{}".format(water_bill))
waterbill(prev_meter,pre_meter)
Enter the previous meter reading: 10
Enter the present meter reading: 18
The number of units of water consumed is 8
The water bill is P80

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS