[英]How can I append something to a result of a function and store that in a Variable in python
I am trying to write a Program that will work out the max. 我试图写一个程序,将最大。 profit and one function is "Steigung" which I need to work out the optimum price. 利润和功能之一就是“ Steigung”,我需要制定出最佳价格。
So what I have is: 所以我有:
def Steigung ():
Propreis=eval(raw_input("Dein hoechster Preis:"))
Satmenge=eval(raw_input("Wie viele leute werden es kaufen:"))
if Propreis >0 and Satmenge >0:
print(-1*Satmenge/Propreis)
and this works fine but what I want to do is to add the Value I specified in "Satmenge" so that the result is for example if Satmenge = 100000 and Propreis = 6 is -16666x+100000 instead of -16666 by itself and how can I store the desired result in a variable to use later? 并且它可以正常工作,但是我想要做的是添加我在“ Satmenge”中指定的值,这样的结果是,例如,如果Satmenge = 100000且Propreis = 6是-16666x + 100000而不是-16666本身,以及如何我将所需的结果存储在变量中以备后用? Thanks in advance 提前致谢
You can return multiple values in the following way: 您可以通过以下方式返回多个值:
def Steigung ():
Propreis=eval(raw_input("Dein hoechster Preis:"))
Satmenge=eval(raw_input("Wie viele leute werden es kaufen:"))
if Propreis >0 and Satmenge >0:
print(-1*Satmenge/Propreis)
return Propreis, Satmenge
And store the returned values like that: 然后像这样存储返回的值:
a, b = Steigung()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.