Wrigs

Edhesive Assignment 9 - 2D Arrays

Apr 17th, 2021 (edited)
815
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a = []
  2.  
  3. for i in range(1):
  4.     a.append([0, 2, 0, 0, 0])
  5.     a.append([0, 2, 0, 0, 0])
  6.     a.append([0, 2, 2, 0, 0])
  7.     a.append([0, 2, 0, 2, 0])
  8.     a.append([0, 2, 0, 0, 2])
  9.  
  10.  
  11. def printArray(b):
  12.     for r in range(len(b)):
  13.         for c in range(len(b[0])):
  14.             print((b[r][c]), end = " ")
  15.         print()
  16.  
  17.  
  18. def reverse(a):
  19.     temp = []
  20.     for i in range(len(a)):
  21.         temp.append(a[len(a) -1 -i])
  22.     return temp
  23.  
  24.  
  25. def flipHorizontal(a):
  26.     temp = a
  27.     for i in range(len(a)):
  28.         temp[i] = reverse(a[i])
  29.     printArray(temp)
  30.  
  31.  
  32. def flipVertical(a):
  33.     a.reverse()
  34.     printArray(a)
  35.  
  36.  
  37. printArray(a)
  38. print()
  39. flipHorizontal(a)
  40. print()
  41.  
  42. a = [[0 , 2 , 0 , 0 , 0],
  43.      [0 , 2 , 0 , 0 , 0],
  44.      [0 , 2 , 2 , 0 , 0],
  45.      [0 , 2 , 0 , 2 , 0],
  46.      [0 , 2 , 0 , 0 , 2]]
  47.  
  48. flipVertical(a)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×