daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Dec 18th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # #Question 5
  2. # def matrix(mat,ln,col):
  3. #     """Create A Matrix with lists of rows as elements"""
  4. #     mat = list(mat)
  5. #     matt = []
  6. #     for i in range (ln):
  7. #         matt.append(mat[i*col:i*col+col])
  8. #          
  9. #          
  10. #     def add_line(line):
  11. #         """Add Line to matrix"""
  12. #         line = list(line)
  13. #         nonlocal matt
  14. #         matt.append(line)
  15. #         nonlocal ln
  16. #         ln=ln+1
  17. #          
  18. #     def add_column(column):
  19. #         """Add add_column to matrix"""
  20. #         for i in range(len(matt)):
  21. #             matt[i].append(column[i])
  22. #              
  23. #         nonlocal col
  24. #         col = col+1
  25. #          
  26. #     def shift_up():
  27. #         """Shifts matrix up"""
  28. #         nonlocal matt
  29. #         temp=(matt.pop(0))
  30. #         matt.append(temp)
  31. #          
  32. #     def shift_down():
  33. #         """Shifts matrix down"""
  34. #         nonlocal matt  
  35. #         temp=(matt.pop(len(matt)-1))
  36. #         matt.insert(0,temp)
  37. #          
  38. #     def shift_right():
  39. #         """Shifts matrix right"""
  40. #         nonlocal matt
  41. #         for i in matt:
  42. #             temp = i.pop(col-1)
  43. #             i.insert(0,temp)
  44. #              
  45. #     def shift_left():
  46. #         """Shifts matrix left"""
  47. #         nonlocal matt
  48. #         for i in matt:
  49. #             temp = i.pop(0)
  50. #             i.append(temp)
  51. #              
  52. #     def transpose():
  53. #         """transpose matrix"""
  54. #         nonlocal matt
  55. #         nonlocal col
  56. #         nonlocal ln
  57. #         res =[]
  58. #         for i in range (col):
  59. #                 res.append(list(map(lambda f:f[i],matt)))
  60. #                  
  61. #              
  62. #         col,ln = ln,col  
  63. #         matt = res
  64. #          
  65. #     def line():
  66. #         """return amount of lines in matrix"""
  67. #         return ln
  68. #     def column():
  69. #         """return amount of column in matrix"""
  70. #         return col
  71. #      
  72. #     def print_matt():
  73. #         """returns dictionary with print method that have a copy of mat"""
  74. #         res =[]
  75. #         for x in matt:
  76. #             res.append(x.copy())
  77. #              
  78. #         def print_one():
  79. #             """returns dict that has a line from mat"""
  80. #             nonlocal res
  81. #             res_o = res.pop(0)
  82. #             def print_two():
  83. #                 """returns a single element from row and delete it"""
  84. #                 nonlocal res_o
  85. #                 return res_o.pop(0)
  86. #                  
  87. #      
  88. #             return {'print':print_two}
  89. #              
  90. #         return {'print':print_one}
  91. #                      
  92. #              
  93. #     return {'print':print_matt,'line':line,'column':column,'add_line':add_line,'add_column':add_column,'shift_up':shift_up,'shift_down':shift_down,'shift_right':shift_right,'shift_left':shift_left,'transpose':transpose}
  94. #      
  95. #      
  96. #      
  97. # m1 = matrix ((1,2,3,4,5,6,7,8),2,4)
  98. # m1['add_line']((1,3,5,7))
  99. # m1['add_column']((2,4,6))
  100. #  
  101. # matrix=m1['print']()
  102. # for _ in range(m1['line']()):
  103. #     line=matrix['print']()
  104. #     for _ in range(m1['column']()):
  105. #         print(line['print'](),end=' ')
  106. #     print()
  107. #      
  108. # print('---------')
  109. #  
  110. #      
  111. # m1['shift_up']()
  112. # m1['shift_right']()
  113. # m1['transpose']()
  114. #    
  115. # matrix=m1['print']()
  116. # for _ in range(m1['line']()):
  117. #     line=matrix['print']()
  118. #     for _ in range(m1['column']()):
  119. #         print(line['print'](),end=' ')
  120. #     print()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top