2017-01-22 7 views
-1
if 1: 
T1=300 
P1=1 
h1=462 
s1=4.42 
hf=29 
sf=0.42 
print("The inlet conditions to compressor are 1atm pressure & 300K") 
Wi=(T1*(s1-sf))-(h1-hf) 
P2= input("What is the final compression pressure? ") 
T2= input("What is the final compression temperature? ") 
h2= float(input("From graph, enthalpy at point 2 is ")) 
s2= float(input("From graph, entropy at point 2 is ")) 
y= float((h1-h2)/(h1-hf)) 
W= float((T1*(s1-s2))-(h1-h2)) 
Wf= float(W/y) 
FOM= float(Wi/Wf) 
print("") 
print("Yield= %f") %(y) 
print("Work reqd per unit mass of gas compressed= %f KJ/kg") %(W) 
print("Work reqd per unit mass of gas liquified= %f KJ/kg") %(Wf) 
print("Figure of Merit= %f") %(FOM) 

圧縮機への入口条件は、1気圧の圧力& 300K 最終圧縮圧力は何ですか? 20 最終圧縮温度はどのくらいですか?グラフから300 、点2におけるエンタルピーが点2におけるエントロピー トレースバック(最新のコール最後)F =%2.74TypeError例外:%用のサポートされていないオペランドタイプ:「NoneType」および「フロート」

収量で、グラフから432 ある: 印刷 ファイル ""、ライン19、( 「=%fを収率」)%は、(Y) TypeError例外:%のためのサポートされていないオペランドのタイプ(S):「NoneType」と「フロート」

+0

'print'関数は' NONE'返すようなコードのあなたの最後の4行はなりますprint機能に%を適用することはできませんし、その後、あなたは '%'演算子を適用します'float'である' y'の値で '%: 'NoneType'と 'float'のサポートされていないオペランドの型を取得します –

答えて

1

あなたの問題はあなたのコードの最後の4行です。それらのステートメントの各式のまわりに括弧()が必要です。それはNone

を返しますので、あなたは

print(("Yield= %f") % (y)) 
print(("Work reqd per unit mass of gas compressed= %f KJ/kg") %(W)) 
print(("Work reqd per unit mass of gas liquified= %f KJ/kg") %(Wf)) 
print(("Figure of Merit= %f") %(FOM)) 
1

あなたは、文字列に書式設定%を適用する必要がありますが、現在、あなたはそれを適用していますNone(値はprint関数によって返されます)。あなたのコードの作業を行うためには、あなたがやるべきこと:

print("Yield= %f" % (y)) 
#    ^moved inside `(...)` of print 

の代わりに:

print("Yield= %f") %(y) 
関連する問題