2017-03-02 72 views
-1

我想打一个程序图中,两个理想气体,但壳推出这个错误:IDEAL GASSES TypeError:不能通过类型为'float'的非整型来乘序列3.4.4?

line 10, in P1 
    return (P*(Vn[c]))/(T[c2]) 
TypeError: can't multiply sequence by non-int of type 'float' 

这是我的计划:

#Prueba de gráfica de gas ideal con volumen molar 
import numpy as np 
from matplotlib import pyplot as plt  
#Sea Vn=miu/densidad... VnNeón=16.82 ml/mol, VnCriptón=32.23 ml/mol 
Vn=[16.82,32.23] 
T=[0.01,60,137,258] 
c=0 #contador del material 
c2=0 #contador temperatura 
def P1(P): #Función de P: 
    return (P*(Vn[c]))/(T[c2]) 
P= list(range(0,800)) 
while c<=1: 
    while c2<=3: 
     print(P1(P),Vn[c],T[c2]) 
     c2=c2+1  
    c=c+1 

我能做什么呢? 我在Windows 10中使用Python 3.4.4。我想获得一个依赖于P的P(P从0变到800)的图形,列表T中的每个温度对于每个摩尔体积的氖和Kripton列表Vn。 为什么我不能用P乘以和划分列表的这些元素? 非常感谢。

+0

你应该输入你的代码,它说“在这里输入代码”。 – user2357112

+0

对不起,我已经发布了代码。 – Moneqz

回答

0

有点调试有很长的路要走。更改你的函数

def P1(P): #Función de P: 
    print(type(P), type(Vn[c]), type(T[c2])) 
    return (P*(Vn[c]))/(T[c2]) 

并运行它打印

<class> 'list' <class 'float'> <class 'float'>

你想多一个list有两个floats,这显然是行不通的。 P = list(range(0, 800)),所以你将需要使用一些索引。我不知道你想做什么,但作为一个例子,下面的函数对我来说运行良好:

def P1(P): #Función de P: 
    #   | just added an index here 
    return (P[0]*(Vn[c]))/(T[c2]) 
相关问题