Screen Shot 2019-11-24 at 8.19.33 PM.png - Num Description For loop Equivalent list comprehension Output of both programs my_list =[5 20 50 for i in

# Screen Shot 2019-11-24 at 8.19.33 PM.png - Num Description...

• 1

This preview shows page 1 out of 1 page.

#### You've reached the end of your free preview.

Want to read the whole page?

Unformatted text preview: Num Description For loop Equivalent list comprehension Output of both programs my_list = [5, 20, 50] for i in my_list = [5, 20, 50] 7 Add 10 to every element. range (len (my_list) ) : my_list = [(i+10) for i my_list [i] += 10 in my_list] [15, 30, 60] print (my_list) print (my_list) my_list = [5, 20, 50] for i in my_list = [5, 20, 50] 2 Convert every element to a string. range (len (my_list) ) : my_list = [str(i) for i my_list[i ] = in my_list ] [ '5' , '20', '50'] str(my_list[i]) print (my_list) print (my_list) inp = input ( 'Enter numbers : ' ) inp = input ( 'Enter 3 Convert user input into a list of my_list = integers. for i in inp. split() : numbers : ' ) my_list = [int(i) for i Enter numbers : 7 9 3 my_list . append ( int (i) ) in inp. split( ) ] print (my_list) print (my_list) [7, 9, 3] my_list = [[5, 10, 15], [2, 3, 16], [100]] sum_list = my_list = [[5, 10, 15], 4 Find the sum of each row in a two- [2, 3, 16], [100]] dimensional list. for row in my list: sum_list = [sum (row) for row in my_list ] [30, 21, 100] sum_list . append ( sum (row) ) print (sum_list) print (sum_list my_list = [[5, 10, 15], Find the sum of the row with the [2, 3, 16], [100]] sum list = my_list = [[5, 10, 15], [2, 3, 16], [100]] 5 smallest sum in a two-dimensional for row in my_list: min_row = min ( [sum(row) 21 table. sum_list . append ( sum (row) ) for row in my_list]) min_row = min (sum_list) print (min_row) print (min_row)...
View Full Document

• Spring '16

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern