Guest User

Untitled

a guest
Jun 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. def dl(l): l[0],l[1]=l[0]*l[1],l[1]-1; return l
  2. co,pow,l,b='0','0',[],''
  3. print "Enter co-eff and power, then enter 'stop' to stop"
  4. while (co!='stop' and pow!='stop'):
  5.     l.append([float(co),float(pow)])
  6.     c,p=raw_input(),raw_input('x ^ ')
  7. l.pop(0)
  8. for a in l[:]:
  9.     dl(a) #Differentiate before processing and output
  10.     if a[1]==0:
  11.         b = b+str(a[0]).rstrip('.0')+'+'
  12.     elif a[1]==1:
  13.         b = b+str(a[0]).rstrip('.0')+'x+'
  14.     else:
  15.         b = b+str(a[0]).rstrip('.0')+'x^'+str(a[1]).rstrip('.0')+'+'
  16. print b.replace(' ','').replace('+',' + ').rstrip(' + ')
Add Comment
Please, Sign In to add comment