Zach Thomas - 3 months ago 8

Python Question

I am supposed to be printing out all values for r (which should be a list of 5 values) but for some reason I am getting an empty list [ ] as the answer. All of the inputs to the function are single values except for the lst variable, which is a list of 5 values. Any idea on why I am getting an empty list? All of the code I am using can be seen below.

`from math import pi`

from sympy import solve

class SolarHeating:

def waterheated(self, T0, T, lst, Cp, Eg, r):

self.m = var('m')

self.T0 = T0

self.T = T

self.lst = lst

self.Cp = Cp

self.Eg = Eg

self.r = r

A = pi * self.r**2

Qt = self.Eg * A

F = [(self.T - self.T0) * self.m * self.Cp / Qt - x for x in self.lst]

self.m = solve(F, self.m)

return self.m

lst = [0, .25, .5, .75, 1.0]

a = SolarHeating()

m = a.waterheated(20, 40, lst, 4.2, .928, .128)

print(m)

Answer

```
...
F = [(self.T-self.T0)*self.m*self.Cp/Qt-x for x in self.lst]
self.m = solve(F,self.m)
return self.m
```

This is most probably a math problem, not programming problem. Print the value of `F`

and check that it really has a solution that `solve()`

should return.

Source (Stackoverflow)

Comments