Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python (begginer) 1) List[ ] build-in data structure is the most commonly used. There are multiple ways to iterate thru a given list [..].For

In Python (begginer) image text in transcribed
image text in transcribed
1) List[ ] build-in data structure is the most commonly used. There are multiple ways to iterate thru a given list [..].For this exercise, we will focus on using - Standard for loop with the list [1,3,5,7,8] - for loop with range( size?) - while loop - list comprehensive. For this exercise, write a function for each of the above methods, and call them from your program. Ist1 =[1,3,5,7,8] Result: for_ i 1,3,5,7,8, for_range 1,3,5,7,8, while_ i 1,3,5,7,8, list comprehension 1,3,5,7,8, 2) Dealing with a nested list; list 1=[[10,20,[300,400, [5000,6000],500],30,40] a. Display list 1 b. Display the items in listl one by one. (using a for loop) c. Display the item in [2] d. Display the item in [2] [2] e. Add 7000 to after item 6000 and display the new list f. Create a new list that flattens the first nested list to: Flat List [10,20,300,400,[5000,6000,7000],500,30, 40] Results: a. the original list [10,20, [ 300,400 , [ 5000,6000],500], 30,40] b. each item of list1: 10 20 [300,400,[5000,6000],500] 30 40 c. list1 [2] is [300,400,[5000,6000],500] d. list 1 [2] [2] is [5000,6000] e. add 7000 to the inner.inner list[2][2] [10,20,[300,400,[5000,6000,7000],500],30,40] f. flatten the 1 st level nested list Flat List [10,20,300,400,[5000,6000,7000],500,30, 40]

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

Step: 3

blur-text-image

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions