Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何在计算器程序中允许多个输入?_Python 3.x - Fatal编程技术网

Python 3.x 如何在计算器程序中允许多个输入?

Python 3.x 如何在计算器程序中允许多个输入?,python-3.x,Python 3.x,我对这一点是全新的,从来没有写过程序,也没有潜入过任何语言。我想出了一个非常粗略的计算器程序来确定重量值 我想问你的问题是,我将如何提示用户进行额外的输入,以允许进行多个计算。到目前为止,它对单个计算工作正常,但显然,您仍然需要记录每个值,然后重新启动的应用程序对用户不是很友好:) Python程序,根据用户输入执行计算,以确定卡车装载量。 def rl(): rl=50 def ft(): 英尺=1 def pl(): pl=450 打印(“欢迎使用BMS链链接重量应用程序!”) 打印(“”)

我对这一点是全新的,从来没有写过程序,也没有潜入过任何语言。我想出了一个非常粗略的计算器程序来确定重量值

我想问你的问题是,我将如何提示用户进行额外的输入,以允许进行多个计算。到目前为止,它对单个计算工作正常,但显然,您仍然需要记录每个值,然后重新启动的应用程序对用户不是很友好:)

Python程序,根据用户输入执行计算,以确定卡车装载量。 def rl(): rl=50 def ft(): 英尺=1 def pl(): pl=450 打印(“欢迎使用BMS链链接重量应用程序!”) 打印(“”) h=无 h为无: 输入值=输入(“请在此处输入网格高度,单位为英尺:”) 尝试: h=int(输入值) 除值错误外: 打印(“{input}不是有效数字!请仅输入数字”。格式(input=input_值)) 如果h==3: 打印(“您选择了36英寸高的网格!”) elif h==3.5: 打印(“您选择了42英寸高的网格!”) elif h==4: 打印(“您选择了48英寸高的网格!”) elif h==5: 打印(“您选择了一个60英寸高的网格!”) elif h==6: 打印(“您选择了72英寸高的网格!”) elif h==7: 打印(“您选择了84英寸高的网格!”) elif h==8: 打印(“您选择了96英寸高的网格!”) elif h==10: 打印(“您选择了一个120英寸高的网格!”) elif h==12: 打印(“您选择了144英寸高的网格!”) 其他: 打印(“{input}不是有效数字!请输入3、3.5、4、5、6、7、8、10或12”。格式(input=input_值)) g=int(输入(“请在此输入仪表尺寸9、11、11.5:”) d=(g) 如果g==9: d=.7 打印(“您选择了一个9G直径!”) elif g==11: d=.4 打印(“您已经选择了11G直径!”) elif g==11.5: d=.38 打印(“您选择了直径11.5G!”) 其他: 打印(“仪表尺寸无效!请选择9、11或11.5”) 退出 打印(“您需要计算多少重量?”) inp=输入(“输入‘英尺’表示每平方英尺重量,输入‘rl’表示卷重,输入‘pl’表示托盘重量:) 结果=0 如果inp==ft: 结果=h*d*1 elif inp==rl: 结果=h*d*50 elif inp==pl: 结果=h*d*450 其他: 打印(“无法识别单位!请选择ft、rl或pl”) 退出 打印(“您需要多少个单位?”) inp=输入(“在此处输入数量:”) txt=“重量等于{}磅” tweight=结果*inp 打印(txt.格式(tweight)) 如果结果*inp>=47001: 打印(“此负载对于卡车来说太重了!”)
elif result*inp不是您的主要问题,但并不是说顶部的三个函数没有做任何事情。它们定义了从未使用过的局部变量。稍后,您将执行
inp==rl
,但是
inp
是一个字符串,
rl
是一个函数。您可能需要
inp==“rl”
,然后去掉这三个函数。
# Python program to perform calculations based on user input to determine truck load size.

def rl():
    rl = 50
def ft():
    ft = 1
def pl():
    pl = 450
    
print("Welcome to BMS ChainLink Weight Application!")
print("                                            ")

h = None
while h is None:
    input_value = input("Please enter your mesh height in FT here: ")
    try:
        h = int(input_value)
    except ValueError:
        print("{input} is not a valid number! please enter a number only".format(input=input_value))
if   h == 3:
        print("You've chosen a 36 inch height mesh!")
elif h == 3.5:
        print("You've chosen a 42 inch height mesh!")
elif h == 4:
        print("You've chosen a 48 inch height mesh!")
elif h == 5:
        print("You've chosen a 60 inch height mesh!")
elif h == 6:
        print("You've chosen a 72 inch height mesh!")
elif h == 7:
        print("You've chosen a 84 inch height mesh!")
elif h == 8:
        print("You've chosen a 96 inch height mesh!")
elif h == 10:
        print("You've chosen a 120 inch height mesh!")
elif h == 12:
        print("You've chosen a 144 inch height mesh!")
else:
        print("{input} is not a valid number! please enter 3, 3.5, 4, 5, 6, 7, 8, 10, or 12".format(input=input_value))
        

g = int(input("Please enter a Gauge size here 9, 11, 11.5: "))

d = (g)
if g == 9:
    d = .7
    print("You've selected a 9G diameter!")
elif g == 11:
    d = .4
    print("You've selected a 11G diameter!")
elif g == 11.5:
    d = .38
    print("You've selected a 11.5G diameter!")
else:
    print("Gauge Size not Valid! Please choose 9, 11, or 11.5")
    quit()
    
print("Which weight do you need to figure?")
inp = input("Enter 'ft' for per sq foot weight, Enter 'rl' for roll weight, Enter 'pl' for pallet weight: ")

result = 0
if inp == ft:
    result = h * d * 1
elif inp == rl:
    result = h * d * 50
elif inp == pl:
    result = h * d * 450
else:
    print("Unit not recognized! Please choose ft, rl, or pl")
    quit()
    
print("How many units of this do you need?")
inp = input("Enter a quantity here: ")

txt = "The weight equals {} pounds"
tweight = result * inp
print(txt.format(tweight))
    
if result * inp >= 47001:
    print("This load is too heavy for a truck!")
elif result * inp <= 47000:
    print("This load will fit on a truck!")