2017-01-22 2 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) 

Die Einlassbedingungen Verdichter sind 1atm Druck & 300K Was ist der endgültige Kompressionsdruck? 20 Wie ist die endgültige Kompressionstemperatur? 300 Aus Diagramm, Enthalpie am Punkt 2 432 Aus Graph ist, Entropie am Punkt 2 ist 2,74Typeerror: Nicht unterstützte Operandentyp (e) für%: ‚NoneType‘ und ‚float‘

Ausbeute =% f Traceback (jüngste Aufforderung zuletzt): Datei "", Zeile 19, in print („Ausbeute =% f“)% (y) Typeerror: nicht unterstützte Operandtyp (e) für%: ‚NoneType‘ und ‚float‘

+0

Die 'print' Funktion gibt' None' und dann wenden Sie die '%' Betreiber dazu mit dem Wert von 'y', was ein' float' ist, so erhalten Sie den Fehler 'nicht unterstützten Operandentyp (en) für%: 'NoneType' und 'float' –

Antwort

1

Ihr Problem in den letzten vier Zeilen des Codes ist. Sie benötigen die Klammern () um jeden Ausdruck in diesen Anweisungen. Sie können nicht % auf print Funktion anwenden, weil es None

Ihre letzten 4 Zeilen Code gibt aussehen sollte

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

Sie sollten % Formatierung auf den String anwenden, aber zur Zeit Sie es bewerben sich auf None (Wert von print Funktion zurückgegeben). Um Ihren Code Arbeit zu machen, sollten Sie tun:

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

statt:

print("Yield= %f") %(y) 
Verwandte Themen