import time import sys t1=time.clock() f1=file('in2_2.txt','r') t=f1.read() k=int(t) count=0 a=0 b=1 n=3 f2=open('out_12_2_2.txt', 'w') f2.write('1=1\n') for i in range(2,k+1): c=a+b a=b b=c count=count+1 f2.write(str(i)+'='+str(c)+'\n') f2.write('no of additions is ' + str(count)+'\n') var_list=[t1,f1,f2,t,k,count,a,b,n,i] memory=0 for i in range(0, len(var_list)): memory = memory+sys.getsizeof(var_list[i]) memory=memory+sys.getsizeof(t1)+sys.getsizeof(memory)+12 '''t2 take same as t1 size and 12 for i of very above loop''' f2.write('memory used is '+str(memory)+' bytes'+'\n') t2=time.clock() f2.write('time taken is '+ str(t2-t1)+' seconds'+'\n') f2.close()