Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def dl(l): l[0],l[1]=l[0]*l[1],l[1]-1; return l
- co,pow,l,b='0','0',[],''
- print "Enter co-eff and power, then enter 'stop' to stop"
- while (co!='stop' and pow!='stop'):
- l.append([float(co),float(pow)])
- c,p=raw_input(),raw_input('x ^ ')
- l.pop(0)
- for a in l[:]:
- dl(a) #Differentiate before processing and output
- if a[1]==0:
- b = b+str(a[0]).rstrip('.0')+'+'
- elif a[1]==1:
- b = b+str(a[0]).rstrip('.0')+'x+'
- else:
- b = b+str(a[0]).rstrip('.0')+'x^'+str(a[1]).rstrip('.0')+'+'
- print b.replace(' ','').replace('+',' + ').rstrip(' + ')
Add Comment
Please, Sign In to add comment