【问题标题】:Python syntax error after using multiple print functions [closed]使用多个打印函数后的Python语法错误[关闭]
【发布时间】:2016-05-29 14:18:57
【问题描述】:

我刚刚开始为我正在从事的项目自学 Python。 这可能是一个相当新手的问题,但是您可以使用打印功能的次数是否有限制?我的代码使用 Print 请求用户输入,但是在第 6 个实例中出现语法错误(无效语法)。据我所知,线路内/周围没有错误。 我正在使用 Python 3.4.4。

问题线是;

print('What is the isentropic efficiency of the intake?')

代码的整体作用是;

# Define cycle
print('What is the cruise altitude (m)?')
altitude = float(input())
print('What is the cruise Mach number?')
print('What is the mass flow?')
W = float(input())
mach0 = float(input())
print('What is the OPR?')
OPR = float(input())
print('What is the TET?')
TET = float(input())
gamma = 1.4
Cp = 1000

# Calculate the freestream properties based on ISA
if altitude < 11000:
    t0 = 288.15 - (6.5*(altitude/1000))
    p0 = 101325*((1-(0.0065*(altitude/288.15)))**5.2561)
else:
    t0 = 288.15 - (6.5*11)
    p0 = (101325*((1-(0.0065*(11000/288.15)))**5.2561))*math.exp((-9.80665*(altitude-11000))/(287.04*t0))

# Calculate Intake Performance

T0 = t0*(1+(((gamma-1)/2)*(mach0**2)))
P0 = p0*((T0/t0)**(gamma/(gamma-1))

print('What is the isentropic efficiency of the intake?')

eta_intake = float(input())
T2 = T0*(1+(((gamma-1)/2)*eta_intake*(mach0**2)))
P2 = P0*((T2/T0)**(gamma/(gamma-1))

【问题讨论】:

  • 您可能希望使用可以为您匹配括号的编辑器。

标签: python printing syntax-error


【解决方案1】:

不,您可以在 Python 中使用任何函数的次数没有限制。错误不是由print 语句的行引起的。
上一行缺少右括号。应该是这样的:

P0 = p0*((T0/t0)**(gamma/(gamma-1)))

print('What is the isentropic efficiency of the intake?')

【讨论】:

    猜你喜欢
    • 2019-07-07
    • 1970-01-01
    • 2016-05-16
    • 1970-01-01
    • 2014-12-31
    • 1970-01-01
    • 1970-01-01
    • 2021-06-24
    • 1970-01-01
    相关资源
    最近更新 更多