make a code where i can check the elements if they are even or odd in a even and odd…
- User
make a code where i can check the elements if they are even or odd in a even and odd column of a matrix . without
using append . here pic the even number box element from the even column in a top to bottom way and pick the odd number box element in the odd column in a bottom to top way. lasty, print it
here input:
floor = np.array([[ '3' , '8' , '4' , '6' , '1'], ['7' , '2' , '1' , '9' , '3'], ['9' , '0' , '7' , '5' , '8'], ['2' , '1' , '3' , '4' , '0']] )
Output: 3 9 1 1 2 4 7 2 4 9 1 8 6
note: do the codes in parts easy way
YOU CANNOT USE ANY BUILT-IN FUNCTION EXCEPT len IN PYTHON. [negative indexing, append is prohibited]
YOU HAVE TO MENTION SIZE OF ARRAY WHILE INITIALIZATION
YOUR CODE SHOULD WORK FOR ANY VALID INPUTS. [Make changes to the Sample Inputs and check whether your program works correctly]
Use Numpy array to initialize the array. You are allowed to use the shape parameter of the numpy array as well.
DO NOT USE DICTIONARY
- Assistant
To solve this problem, we need to iterate through the matrix based on the column indices, collecting even numbers from even index columns and odd numbers from odd index columns. Here's a step-by-step guide to achieve this:
- Initialize variables to store the results for even and odd indexed columns.