打印无效语法?[Python3]

2024-04-25 14:28:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图写一个程序,将做一些简单的数学游戏,但我遇到了多个错误。在

打印后的字符串在括号中,因为python3。 如果我试图输入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")

Tags: lockinputyourbaseifintdecimalprint
1条回答
网友
1楼 · 发布于 2024-04-25 14:28:29

你在电话上忘了一个结案的妄想症

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

另外,我假设这是在函数中,并且需要return,但是如果返回值被命中,print('seconds')将不会被执行。无法访问。

相关问题 更多 >