* > 反复循环,提示用户选择一个选项,然后运行
适当的命令并重复,直到用户选择退出。选项有: 0 退出程序;1 计算特定值集合的流速;2 计算雷诺数,3 绘制预期流量。如果用户选择任何其他选项,程序必须不断要求他们选择一个有效值,直到他们这样做。*
而我<=3:
i=input (" Please enter a number between 0-3:")
if i==0:
print " program will exit."
break
elif i==1:
print ( " To calculate flow rate please input these values:" )
pressure = input (" Please enter pressure drop in pascals: " )
radius = input (" Please enter radius in m: " )
viscosity = input (" Please enter viscosity of liquid in Pa.s: ")
Length= input (" Please enter length in m: " )
Flowrate = (pressure * pi *(radius**4))/ ( 8 * viscosity * Length)
print " Therefore, flow rate is " , Flowrate
print " Program will run again for user to calculate flow rate..."
elif i==2:
print ( " To calculate reynolds number please input these values:" )
q=input ("Please enter a value for flow rate in m^3/s")
radius = input (" Please enter radius in m: " )
density=input (" Please enter density in kg/m^3 : " )
viscosity = input (" Please enter viscosity of liquid in Pa.s: ")
Rno=(2*q*radius*density)/(viscosity*pi*radius*radius)
elif i==3:
print " not implemented yet."
else:
print " Program will start again!"
***new edited post***