mardi 12 mai 2020

how to print a pattern using 1's in the form of plus sign using numpy array

Given a single positive odd integer 'n' greater than 2, create a NumPy array of size (n x n) with all zeros and ones such that the ones make a shape like '+'. The lines of the plus must be present at the middle row and column.Given input and output as below

Input 1:

3

Output 1:

[[0 1 0]

[1 1 1]

[0 1 0]]

Aucun commentaire:

Enregistrer un commentaire