Advertisement
kajs54

ex4 s10

May 4th, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. from numpy import *
  2. A=array([str]*100)
  3. B=array([str]*100)
  4. R=array([str]*100)
  5. def saisie():
  6. while True:
  7. n=int(input("n="))
  8. if 2<n<20: break
  9. return n
  10. def remplir1(n):
  11. for i in range(n):
  12. while True:
  13. A[i]=input("A["+str(i)+"]:")
  14. if 9<=len(A[i])<=20 and A[i].isnumeric(): break
  15. return A,n
  16. def remplir2(n):
  17. for i in range(n):
  18. while True:
  19. B[i]=input("B["+str(i)+"]:")
  20. if 9<=len(B[i])<=20 and B[i].isnumeric(): break
  21. return B,n
  22. def remplir3(A,B,n):
  23. y=0
  24. for i in range(n):
  25. R[i]=str(int(A[i])+int(B[i]))
  26. return R,n
  27. def afficher(R,n):
  28. for i in range(n):
  29. print(R[i],end="-")
  30. print()
  31. n=saisie()
  32. A,n=remplir1(n)
  33. B,n=remplir2(n)
  34. R,n=remplir3(A,B,n)
  35. afficher(R,n)
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement