0
好的 - 我試圖讓Python函數接受來自另外兩個函數的變量。這可能嗎 ?Python:1函數可以接受來自2個不同函數的變量
我正在嘗試做下面的一個樣本(我已經將原始代碼模擬下來 - 在此處輸入)。希望你能理解我想要做的事情。簡而言之,我有Rectangle(),它調用Extras(),我希望將Rectangle和Extras的輸出發送到Calculate_Deposit()。
這可能嗎?
def calculate_deposit(total_cost, extras):
deposit_percent = float(raw_input("Enter Deposit % (as a decimal) of Total Cost: "))
months_duration = float(raw_input("Enter the number of months client requires: "))
if deposit_percent >0:
IN HERE JUST SOME CALCULATIONS
else:
print "The total amount required is: ", total_cost
def rectangle(width, height, depth, thickness):
type = raw_input("Enter lowercase c for concrete: ")
if type == 'c':
output = IN HERE JUST COME CALCULATIONS
else:
return raw_input("Oops!, something went wrong")
print output + extras()
total_cost = calculate_deposit(output, extras)
def extras():
type = float(raw_input("Enter 1 for lights: "))
if type == 1:
light = 200
print "The cost of lights are: ", light
return light
else:
return raw_input("No extras entered")