Write a program in Python to
take the input of water consumption (in litres per week) by any 3 members of your family.
Then show the total and average water consumption of these family members.
Also display the labels as "HIGH Consumption" or "LOW Consumption" in front of the names of the respective family members after comparing their individual consumption with the average of 3.
Answers
Answered by
4
Answer:
def compare(val):
if(val >= avg):
return "High consumption"
else:
return "Low consumption"
m1 = float(input("Water consumption by Father per week (in litre): "))
m2 = float(input("Water consumption by Mother per week (in litre): "))
m3 = float(input("Water consumption by Son per week (in litre): "))
total = m1+m2+m3
avg = total/3
print("Total consumption: %.2f\n"%total)
print("Average consumption: %.2f\n"%avg)
print(compare(m1)+": Father\n"+compare(m2)+": Mother\n"+compare(m3)+": Son\n")
Similar questions