import time import sys t1=time.clock() f1 = file('in1_2.txt' , 'r') t=f1.read() f1.close k=int(t) c=0 x=1 f2=open('out_12_sec1_2.txt', 'w') for i in range(1,k+1): x=x*i c=c+1 f2.write(str(i)+'='+str(x)+'\n') f2.write('no of multiplications is '+ str(c)+ '\n') var_list=[t1,f1,f2,t,k,c,x,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 '''t1 take same as t2 and 12 for i of 2nd 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