At Westonci.ca, we connect you with the answers you need, thanks to our active and informed community. Discover in-depth answers to your questions from a wide network of experts on our user-friendly Q&A platform. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.

100 POINTS PLEASE HELP
Create and initialize a 5 x 5 array as shown below.
0 2 0 0 0
0 2 0 0 0
0 2 2 0 0
0 2 0 2 0
0 2 0 0 2

First, write a printArray() function that prints out the array. Use a single parameter in the definition of the function, and pass the array you created above as the parameter. Call the function so it prints the original array.

Then write a flipHorizontal() function that flips the contents of the array horizontally and prints the result. This means that the values in each row should be reversed (look at the second array in the sample run of the program for clarity). Again, this function should pass the original array as the parameter. Within your flipHorizontal() function, call the printArray() function to print the new array that has been horizontally flipped.

Reset the array back to the original 5 x 5 array we started with.

Then write a flipVertical() function that flips the contents of the array vertically and prints the result. This means that the values in each column should be reversed (look at the third array in the sample run of the program for clarity). Again, this function should pass the original array as the parameter. Within your flipVertical() function, call the printArray() function to print the new array that has been vertically flipped.

The sample run below shows how your code should print the original array, followed by the horizontally-flipped array, followed by the vertically-flipped array. Notice that the output below includes blank lines between each of the three arrays - yours should do the same.

Code should be able to do this

0 2 0 0 0
0 2 0 0 0
0 2 2 0 0
0 2 0 2 0
0 2 0 0 2


0 0 0 2 0
0 0 0 2 0
0 0 2 2 0
0 2 0 2 0
2 0 0 2 0


0 2 0 0 2
0 2 0 2 0
0 2 2 0 0
0 2 0 0 0
0 2 0 0 0

Sagot :

Answer:

hope this helped ,do consider giving brainliest

Explanation:

import numpy as np

#PrintArray Function

def printArray(array):

for i in range(len(array)):

for j in range(len(array[i])):

print(array[i][j], end= " ")

print()

#Flip horizontal function

def flipHorizontal(array):

#reversing the order of arrays

array2 = np.fliplr(array).copy() printArray(array2)

#Flip Vertical function

def flipVertical(array):

#Preserving the order of array and reversing each array.

array3 = np.flipud(array).copy() printArray(array3)

#Main() function def main():

array = [[0,2,0,0,0],[0,2,0,0,0],[0,2,2,0,0],[0,2,0,2,0],[0,2,0,0,2]]

print("The array: \n")

printArray(array)

print("\nFlipped horizontally: \n") flipHorizontal(array)

print("\nFlipped vertically: \n") flipVertical(array)

if __name__=="__main__":

main()Explanation:

Answer:

Answer:

hope this helped ,do consider giving brainliest

Explanation:

import numpy as np

#PrintArray Function

def printArray(array):

for i in range(len(array)):

for j in range(len(array[i])):

print(array[i][j], end= " ")

print()

#Flip horizontal function

def flipHorizontal(array):

#reversing the order of arrays

array2 = np.fliplr(array).copy() printArray(array2)

#Flip Vertical function

def flipVertical(array):

#Preserving the order of array and reversing each array.

array3 = np.flipud(array).copy() printArray(array3)

#Main() function def main():

array = [[0,2,0,0,0],[0,2,0,0,0],[0,2,2,0,0],[0,2,0,2,0],[0,2,0,0,2]]

print("The array: \n")

printArray(array)

print("\nFlipped horizontally: \n") flipHorizontal(array)

print("\nFlipped vertically: \n") flipVertical(array)

if __name__=="__main__":

main()Explanation:

Explanation: