Question: Help making PYTHON code more modular with function getAreaRecs ( ) which totals areas of windows and doors. Image helps. My code: import math def
Help making PYTHON code more modular with function getAreaRecs which totals areas of windows and doors. Image helps.
My code:
import math
def calculatepaintneededlength width, height, doors, windows:
totalwallarea length width height
totaldoorarea sumdoorlength doorwidth for door in doors
totalwindowarea sumwindowlength windowwidth for window in windows
totalwallarea totaldoorarea totalwindowarea
gallonsneeded totalwallarea
return gallonsneeded
def getvalidinputprompt validationfunc:
while True:
try:
value inputprompt
value floatvalue
if validationfuncvalue:
return value
else:
printInvalid input. Please try again."
except ValueError:
printInvalid input. Please enter a valid number."
def validatepositivevalue:
return value
def main:
length getvalidinputEnter the length of the room in feet: validatepositive
width getvalidinputEnter the width of the room in feet: validatepositive
height getvalidinputEnter the height of the room in feet: validatepositive
totalwallarea length width height
printTotal wall area before subtracting doors and windows:", totalwallarea
printExcellent let's get your windows and doors in now."
numdoors intgetvalidinputEnter the number of doors must be greater than : validatepositive
doors length: getvalidinputfEnter the length of door i in feet: validatepositive
"width": getvalidinputfEnter the width of door i in feet: validatepositive
for i in rangenumdoors
numwindows intgetvalidinputEnter the number of windows: validatepositive
windows length: getvalidinputfEnter the length of window i in feet: validatepositive
"width": getvalidinputfEnter the width of window i in feet: validatepositive
for i in rangenumwindows
gallonsneeded calculatepaintneededlength width, height, doors, windows
printfYou will need to buy mathceilgallonsneeded gallons of paint."
printYou will need exactly", gallonsneeded, "gallons of paint for the walls after subtracting the doors and windows."
if namemain:
main
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
