1

我正在尝试编写一个程序来为视频游戏做一些简单的数学运算,但是我遇到了多个错误。

由于 Python 3,Print IS 之后的字符串在括号中。如果我尝试输入 1.5 或类似“FCS”的值,我也会收到“计算错误”

import decimal
print("ARMORED CORE V - FCS SIMULATION")
print("This program will calculate lock times for weapons combined with their FCS in           Armored Core V")
print("----------------------------------------------------------------------------")

#Base Weapon Lock/FCS Lock Percentage (150=1.5)/60
#Seidenbaum at 421 Base Lock
#421/1.5/60 is lock time (4.67 seconds)
#Subcomputer: Base Weapon Lock/FCS Lock Percentage/Subcomp Lock Percentage  (320=3.02)/Second Subcomp/60
#Subcomps: 421/1.5/3.02/60 (1.54 Seconds)
#Dual Subcomps: 421/1.5/3.02/3.02/60 (0.5 Seconds)

while (1 == 1):
    command = input("\nTo begin, type 'compute'\nThen enter your weapon's Base Lock Time\nThen your FCS' Lock Computation\nAnd then how many Subcomputers you have\nyou can also type help [ compute // help ]")
    if command == "help":
        print("\nFollow the instuctions as prompted\n\nI will also display the Lock Times and Subcomp Acceleration for FCSes and Subcomputers")
        print("--FCSes--\nUFC-11 GLANCE - 1.7 Lock Computation\nFCS-09 YASAKANI - 1.05 Lock Computation\nKV-1T2/OTKRYT - 0.75 Lock Computation\nFCS-07/Lr UZUME - 1.8 Lock Computation\nSEHER FCS199 - 1 Lock Computation\nPREDIRE FCS190 - 1.5 Lock Computation\n--SUBCOMPUTERS--\nSUBCOMPUTER USC-1 DHANBAD - 3.02 Lock Improvment\nSUBCOMPUTER SBC-9 TSUKUYOMI - 3.06 Missile Lock Improvement [Enter Normally]")
    if command == "compute":
        baselock = input("\n\nEnter your weapon's Base Lock Time >> ")
        fcs = input("\nEnter your FCS' Lock Computation as a Percentage >> ")
        subcompone = input("\nEnter your first Subcomputer's lock improvment\n Enter '1' if you don't have any subcomps >> ")
        subcomptwo = input("\nEnter your second Subcomputer's lock improvment\n Enter '1' if you don't have a second subcomputer >> ")
        try: 
locktime = float(int(baselock)//int(decimal.decimal(fcs)//int(decimal.decimal(subcompone)//int(decimal.decimal(subcomptwo)//60)
                return(locktime)
                print("Seconds")
        except ValueError:
            print("error in calculation")
4

1 回答 1

2

你忘记了就行了

locktime = float(int(baselock)//int(decimal.decimal('fcs')//int(subcompone)//int(subcomptwo)//60))

另外,我假设这是在函数中并且return是必需的,但print('seconds')如果返回被命中则不会执行。这是无法到​​达的。

于 2013-08-27T04:50:02.447 回答