import time import sys t1=time.clock() f1=file('in13_2.txt','r') t=f1.read() if int(t[len(t)-1])<=9: t=t+'e' comp=0 count_add=0 index=[] val=[] k=0 i=0 j=1 m=0 while(k>=0 and k96 and ord(t[j])>96): comp=comp+3 i=i+1 j=j+1 k=k+1 count_add=count_add+3 elif (j96 and ord(t[j])<96): comp=comp+3 while(ord(t[j])<96): comp=comp+1 j=j+1 n=int(t[i+1:j]) m=m+n i=j j=j+1 k=k+1 count_add=count_add+4 else: break f2=open('out_12_13_2.txt', 'w') f2.write(str(m)+'\n') f2.write('no of additions is ' + str(count_add)+'\n') f2.write('no of comparisons is ' + str(comp)+'\n') var_list=[t1,f1,f2,t,comp,count_add,val,k,i,j,m] 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') f1.close() f2.close()