I am new to Python, and am trying to create a function which creates lists with different material parameters from user inputs as shown in the code below.
def material():
layers = int(raw_input("State the number of material layers in the wall (0 for default material): "))
rho = [] # Density [kg/m3]
c = [] # Heat capacity [J/(kg K)]
k = [] # Heat conductivity [W/(m K)]
#a = [] # Thermal diffusivity [m2/s]
d = [] # Thickness of material [m]
# Saveing material properties
if layers == 0:
rho.append(2300)
c.append(900)
k.append(1.6)
d.append(3.2)
layers = 1
else:
for i in range(layers):
print "\n" "Define thermal properties for material", i+1,"(starting from left)"
rho.append(float(raw_input("Density [kg/m3]: ")))
c.append(float(raw_input("Heat capacity [J/(kg K)]: ")))
k.append(float(raw_input("Heat conductivity [W/(m K)]: ")))
d.append(float(raw_input("Thickness [m]: ")))
return ???
How should I return rho, c, k, d and layers so I am able to e.g. print – or use the value of – e.g. the second item in the list of d?
print d[1]