I am trying to write a heater function but I am having a few difficulties. I am fairly new to Python.
I want my heater to run for 15000 seconds but for the first 120 seconds (inclusive of 120) I want it to follow a linear path T = 0.0804 * t + 16.081
and then after 120 seconds I want it to remain constant for the rest of the remaining time at the final temperature found from the linear equation.
The code I have written is below which I am getting errors with
import math, numpy as np
from random import *
a = 0.0804
time = range(15001)
for time in xrange(15001):
if 0 < = time < = 120:
Temp = a * np.array(time) + 18.3
elif time > 121:
Temp = Temp[120]
Errors:
TypeError
Traceback (most recent call last)
/Library/Python/2.7/site-packages/ipython-1.0.0_dev-py2.7.egg/IPython/utils/py3compat.pyc in execfile(fname, *where)
202 else:
203 filename = fname
--> 204 builtin.execfile(filename, *where)
/Users/mariepears/Desktop/heaterfunction.py in <module>
() 16 print T
17 elif t>121:
---> 18 T=T[120]
TypeError: 'int' object is not subscriptable`