Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simplified Question: Basically you must sum up index 1 of every row, and you must sum up index 2 of every row. You must return

Simplified Question: Basically you must sum up index 1 of every row, and you must sum up index 2 of every row. You must return every array that was summed up and doesn't go past the capacity (500). If it does past the capacity provided then make sure to just return the arrays that doesn't go past 500 instead of overloading.

EXAMPLE:

This specific code below should return "[[[1, 20, 3], [2, 150, 7], [3, 165, 9]] 335, 19]] "

335 is the sum of ALL index 1, and 19 is the sum of ALL index 2 from every array. This should work for any arrays and not just specified to this type.

CODE:

from copy import deepcopy

def find_subset(ID, c): if len(ID) == 0 or m ## problem lies in this method, it only returns a single number for i in range(len(ID)): ## row for j in range(len(ID[i])): ## column list1 = ID[0] maxE = list1[1] + list1[2] v = ID[i][1] + ID[i][2] if (v maxE): maxE = v array = ID[i][j] return array

if __name__ == "__main__": ID = [ [1, 20, 3], [2, 150, 7], [3, 165, 9], ]

Here is the answer but how can I do this WITHOUT numpy? I need to use just a for loop for this and .appends

image text in transcribed

import numpy as np num= num np.array([[1, 20, 3], [2, 150, 7], [3, 165, 9]]) array([[ 1, 20, [ 2, 150, [3, 165, 3], 7], 9]]) sum_column sum_column np. sum(num, axis ) # axis a means column wise array([ 6, 335, 19]) for loop1 in range(len(sum_column)): if (sum_column[loop1]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

Discuss different types of external growth strategies.

Answered: 1 week ago

Question

LO1 Understand risk management and identify its components.

Answered: 1 week ago