Python解释器说paintRequiredCeiling是未定义的。我无法在代码中找到任何错误。目标是让程序从用户那里获取输入,然后计算油漆工作所需的成本/小时数。
import math
def main():
# Prompts user for sq and paint price
totalArea = float(input("Total sq of space to be painted? "))
paintPrice = float(input("Please enter the price per gallon of paint. "))
perHour = 20
hoursPer115 = 8
calculate(totalArea, paintPrice, perHour, hoursPer115)
printFunction()
def calculate(totalArea, paintPrice, perHour, hoursPer115):
paintRequired = totalArea / 115
paintRequiredCeiling = math.ceil(paintRequired)
hoursRequired = paintRequired * 8
costOfPaint = paintPrice * paintRequiredCeiling
laborCharges = hoursRequired * perHour
totalCost = laborCharges + costOfPaint
def printFunction():
print("The numbers of gallons of paint required:", paintRequiredCeiling)
print("The hours of labor required:", format(hoursRequired, '.1f'))
print("The cost of the paint: $", format(costOfPaint, '.2f'), sep='')
print("Total labor charges: $", format(laborCharges, '.2f'), sep='')
print("Total cost of job: $", format(totalCost, '.2f'), sep='')
main()