Extraction of rows and columns of a two-dimensional array

Asked 2 years ago, Updated 2 years ago, 218 views

I am currently creating my own Python module.
I would like to extract only the numbers in the two-dimensional array within Python's self-made module.
This is for checking operation, so please do not change this program, but only change the program of the self-made module below

import data_conduct asda
data = [["Q1", "Q2", "Q3", "Q4", "Q5"],
        ["A", 90, 35, 60, 40] ,
        ["B", 80, 25, 61, 35] ,
        ["C", 85, 40, 70, 45]

begin = 1
end = 5
print(data)

The top and bottom are separate files, and the bottom is the self-made module (conduct.py).
data_conduct.py

defind_max(data, begin, end):
    del data [0]
    print(data)

I'd like to process the two-dimensional array I just mentioned in my own module, but I don't know what to do.

data=[90,35,60,40],
     [80, 25, 61, 35],
         [85, 40, 70, 45]]

Supplementary

def find_max(data, begin, end): Do you mean you want to do something about the processing in ? In that case, does begin or end mean anything? If so, how is it used?

def find_max(data, begin, end):understanding the processing in
I would like to take out the begin and end values from the begin to the end columns like 90, 80, 85, and end to the end columns like 40, 32, 45 in column (end-1) in the two-dimensional array.
You do not need to check if the begin or end values are outside the array range or the size is reversed.

python

2022-09-30 22:05

1 Answers

If you want to create a response to a comment as defind_max(data, begin, end):, it will look like this:
del data[0] can be processed in one line, including parts equivalent to .

defind_max(data, begin, end):
    data = [ x [ begin : end ] for x in data[1:]]
    print(data)


2022-09-30 22:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.