使用多个打印函数后出现Python语法错误
我刚刚开始为我正在从事的一个项目自学Python。 这可能是一个相当新手的问题,但是您可以使用打印功能的次数有限制吗?我的代码正在使用Print请求用户输入,但是第6个实例出现语法错误(无效语法)。据我所知,生产线内/周围没有错误。 我正在使用Python 3.4.4 问题线是使用多个打印函数后出现Python语法错误,python,printing,syntax-error,Python,Printing,Syntax Error,我刚刚开始为我正在从事的一个项目自学Python。 这可能是一个相当新手的问题,但是您可以使用打印功能的次数有限制吗?我的代码正在使用Print请求用户输入,但是第6个实例出现语法错误(无效语法)。据我所知,生产线内/周围没有错误。 我正在使用Python 3.4.4 问题线是 print('What is the isentropic efficiency of the intake?') 代码的整体作用是: # Define cycle print('What is the cruise
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))
#定义周期
打印(‘巡航高度(米)’)
高度=浮动(输入()
打印(‘巡航马赫数是多少?’)
打印(“质量流量是多少?”)
W=浮点(输入()
马赫0=浮动(输入()
打印('什么是OPR?')
OPR=浮点(输入()
打印(‘什么是春节?’)
TET=float(输入())
伽马=1.4
Cp=1000
#基于ISA计算freestream属性
如果高度<11000:
t0=288.15-(6.5*(海拔/1000))
p0=101325*((1-(0.0065*(海拔/288.15))**5.2561)
其他:
t0=288.15-(6.5*11)
p0=(101325*((1-(0.0065*(11000/288.15))**5.2561))*数学实验((-9.80665*(海拔11000))/(287.04*t0))
#计算进气性能
T0=T0*(1+((伽马-1)/2)*(马赫数**2)))
P0=P0*((T0/T0)**(伽马/(伽马-1))
打印(“进气的等熵效率是多少?”)
eta_进气=浮动(输入()
T2=T0*(1+((伽马-1)/2)*eta_进气*(马赫数**2)))
P2=P0*((T2/T0)**(伽马/(伽马-1))
否,Python中任何函数的使用次数没有限制。错误不是由带有print
语句的行引起的。前一行缺少右括号。应该是这样的:
P0 = p0*((T0/t0)**(gamma/(gamma-1)))
print('What is the isentropic efficiency of the intake?')
您可能希望使用一个编辑器来匹配括号。