0
OK - 他の2つの関数から変数を受け入れるPython関数を取得しようとしています。これは可能ですか?Python:1つの関数が2つの異なる関数から変数を受け入れることができます
私が下にしようとしているもののサンプル(私はここに入力するために元のコードをシミュレートしました)。うまくいけば、私がやろうとしていることのうちにあなたが得られるはずです。簡単に言えば、Extras()を呼び出すRectangle()があり、RectangleとExtrasの出力をCalculate_Deposit()に送信する必要があります。
これは可能ですか? rectangle
で
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")