Problem 5.1 - listlib.lengths() [5 points] Define a function listlib.lengths which accepts a list of lists as an argumen

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Problem 5.1 - listlib.lengths() [5 points] Define a function listlib.lengths which accepts a list of lists as an argumen

Post by answerhappygod »

Problem 5 1 Listlib Lengths 5 Points Define A Function Listlib Lengths Which Accepts A List Of Lists As An Argumen 1
Problem 5 1 Listlib Lengths 5 Points Define A Function Listlib Lengths Which Accepts A List Of Lists As An Argumen 1 (61.65 KiB) Viewed 40 times
Problem 5.1 - listlib.lengths() [5 points] Define a function listlib.lengths which accepts a list of lists as an argument, and returns a new list of integers, containing the lengths of all inner lists. Clearly, the result should have the same length as the outer) list input. Again, you should not modify any of the lists in any way. For example, the function call lengths (11,2), L'a', 1100, 101, 'b'])) should return a list equal to [2, 3). Hint: This is no more difficult than the convert_inputs function from the previous assignment, don't let the data type of the Couter) list's clements lead you to overthinking. --) More specifically, you already implemented the "transform" I so, S... 11 | floatisc), float(sil.... float(n-1)]. The "transform" in this problem, ie, Ilo,..., illen(Co), len(en).... lenen-1) isn't really that different Problem 5.2-list11b. longest() [10 points] Define a function 1st lib. longent which accepts a non-empty list of lists as an argument, and returns the longest (sub-)list. You can assume that the input list is non-empty (ie, contains at least one (sub-)list). Just to be clear, you should return the (sub-list itself, not it's length, or a copy of the sub-list, or anything else. If there are ties, then you should retum the carliest list. Finally, once again you should not modify the input list in any way. For example, the function call longest 111.21, 11100, 101, +11) should simply return the second list from the input argument (ixta100, 101, 1). Or, for a little less contrived input, the call longent (1,0), 11,2,31. 12, 41, 11, 13,2,111) should return the second list from the input argument (ie, 11,2,31); this also illustrates the tiebreaker requirement (both (1,2,31 and (3, 2, 11 have maximal length, so the earliest wax returned) Remark This is fairly similar to the problems we worked on the lecture of Apr ist, and particularly the loop to calculate the minimal value rictly puu only need that works for women the input there wurfunction shall work well in tur in
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply