【发布时间】:2013-09-08 19:03:16
【问题描述】:
我正在为我的班级编写一个简短的程序,但我被困在最后一部分。当我运行程序时,一切都正常运行,直到我尝试将两个单独函数的成本相乘以定义另一个函数。我该如何纠正这个问题?
这是完整的代码:
def main():
wall_space = float(input('Enter amount of wall space in square feet: '))
gallon_price = float(input('Enter the cost of paint per gallon: '))
rate_factor = wall_space / 115
total_gallons(rate_factor, 1)
total_labor_cost(rate_factor, 8)
total_gal_cost(rate_factor, gallon_price)
total_hourly_cost(rate_factor, 20)
total_cost(total_hourly_cost, total_gal_cost)
print()
def total_gallons(rate1, rate2):
result = rate1 * rate2
print('The number of gallons of required is: ', result)
print()
def total_labor_cost(rate1, rate2):
result = rate1 * rate2
print('The hours of labor required are: ', result)
print()
def total_gal_cost(rate1, rate2):
result = rate1 * rate2
print('The cost of the paint in total is: ', result)
print()
def total_hourly_cost(rate1, rate2):
result = rate1 * rate2
print('The total labor charges are: ', result)
print()
def total_cost(rate1, rate2):
result = rate1 * rate2
print('This is the total cost of the paint job: ', result)
print()
main()
伙计们,我很绝望!
【问题讨论】:
标签: python function definition multiplication