fork download
  1. from sys import stdin
  2. quotient=[]
  3. deno={}
  4. num={}
  5. m=int(input("Enter max power of denominator "))+1
  6. flagm=m
  7. n=int(input("Enter max power of numerator "))+1
  8. flagn=n
  9.  
  10. print "Enter the denominator coefficients in.. Coeff of higher power in decreasing order"
  11. for i in range(m):
  12. deno[flagm]=float(input())
  13. flagm=flagm-1
  14. print "Enter the numerator coefficients in.. Coeff of higher power in decreasing order"
  15. for j in range(n):
  16. num[flagn]=float(input())
  17. flagn=flagn-1
  18.  
  19. it=int(input("Enter no. of desired coeff in Z-Transform "))
  20.  
  21. for i in range(it):
  22. k1=max(deno.keys())
  23. k2=max(num.keys())
  24. quotient.append(num[k2]/deno[k1])
  25. flag=k2-k1
  26. del num[k2]
  27. for j in range(1,m):
  28. z=num[i]*quotient[-1]
  29. if (i+flag) in num.keys():
  30. num[i+flag]=num[i+flag]-z
  31. else:
  32. num[i+flag]=-z
  33. if not bool(num):
  34. break
  35.  
  36.  
Runtime error #stdin #stdout #stderr 0.01s 7252KB
stdin
Standard input is empty
stdout
Enter max power of denominator 
stderr
Traceback (most recent call last):
  File "prog.py", line 5, in <module>
EOFError: EOF when reading a line