Question: # Function to calculate energy cost for a given age def calculate _ child _ cost ( age ) : if age < = 4
# Function to calculate energy cost for a given age
def calculatechildcostage:
if age :
return
elif age :
return
elif age :
return
elif age :
return
else:
return # Full price for adults
# Function to calculate energy cost based on inputs
def calculateenergycostresidents children, tier:
basepriceperweek
partnerdiscount
tierdiscounts B: S: G:
# Calculate base cost
basecost basepriceperweek residents
# Apply tier discount
basecost basecost tierdiscountstier
# Apply partner discount if there are two residents
if residents :
basecost partnerdiscount
# Calculate children's energy cost
childrencost sumcalculatechildcostage for age in children
# Calculate total cost
totalcostperweek basecost childrencostbasecost
# Convert to monthly and annual costs
totalcostpermonth totalcostperweek # Average number of weeks in a month
totalcostperyear totalcostperweek
return totalcostperweek, totalcostpermonth, totalcostperyear
# Function to get user input and generate energy cost quote
def generatequote:
print
printWelcome to SmartEco Energy Solutions"
print
printLet us help you manage your energy usage."
while True:
residents intinputEnter the number of residents :
if residents or residents :
printPlease enter a valid number of residents."
continue
children
numchildren intinputEnter the number of children :
for i in rangenumchildren:
age intinputfEnter the age of child i :
children.appendage
while True:
tier inputWhat tier of energy plan would you like?
BasicSilverGold: upper
if tier not in BSG:
printPlease enter a valid tier."
continue
else:
break # Break out of the tier input loop if a valid tier is entered
weeklycost monthlycost annualcost calculateenergycostresidents children, tier
print
Thank you. Your monthly energy cost is:
printf$ weeklycost:f per week"
printf$ monthlycost:f per month"
printf$ annualcost:f per annum
anotherquote inputDo you need another quote ynlower
if anotherquote y:
printHave a sustainable day."
break
# Main function
if namemain:
generatequote
Draw a flow chart based on the above python program
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
