我正在尝试将0的值替换为.5,或在初始输入时替换为1/2。你知道吗
例如,我试图在添加函数之前完成它。我只需要为输入重新定义0的值,并且只为0本身的单个实例重新定义。不是10+的值。你知道吗
以下是项目信息:
IN = input("Enter IN: ")
N = input("Enter N: ")
NP = input("Enter NP: ")
### These two lines are the part I can't get to work:
if digit == float(0):
digit = float(.5)
###
init = (float(IN)*(float(1)/float(2)))
baselimiter = - (float(N)*(float(1)/float(2))) + ((float(IN)*
(float(1)/float(2))) * (float(NP)*(float(1)/float(2))))
lset = init + baselimiter
limitconverto1 = (lset / init) * (init / lset)
infalatetoinput = (((init * float(IN))) / init )
limit = limitconverto1 * infalatetoinput
result = limit
print(result)
所以这里有一个代码可以满足你的需要。你知道吗
老实说,这很管用,但我不明白你为什么这么做。你做了一堆奇怪的计算,比如用同一个数乘和除。。。你知道吗
声明变量时,可以使用一行程序:
单行线是
for
循环或if
语句(或两者),它们在声明变量时位于一行而不是多行。它们只能用于声明变量。我建议的一行是多行:有关单行线的详细信息:One-Liners - Python Wiki
我希望我以前的答案编辑完全回答你的问题,更多的澄清,我将在评论上提供
相关问题 更多 >
编程相关推荐