Quick assignment: Lists For this assignment, you must create and make use of lists and master the basic skills in() and append(). 1. Create a new list. The list should be called "colour_list". The list should contain the following items: Red, Blue, Purple, Green, Orange, Beige, Peach. 2. Create another list now, which is called "fruit_list". This list should contain: Apple, Banana, Orange, Prune, Pineapple Peach. 3. Print both lists 4. Now create a new EMPTY list and call it "fruits_that_are_colours" 5. Iterate (using a for loop) through the first list, and check whether it is in the second list. if it is, add it to the third list with append() 6. Now print the list of fruits that are colours. Done. For a little extra challenge (optional), make use of functions to make the code slicker. Try to keep your main code as only calls to functions. Take note that lists created INSIDE functions will not "exist" outside of the functions unless you define them as global variables. However, if you define a list outside a function, it can be modified outside

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Programming

Title
Always all these lists. bla bla always lists...
Quick assignment: Lists
For this assignment, you must create and make use of lists and master the basic skills in() and
append().
1. Create a new list. The list should be called "colour_list". The list should contain the following
items: Red, Blue, Purple, Green, Orange, Beige, Peach.
2. Create another list now, which is called "fruit_list". This list should contain: Apple, Banana,
Orange, Prune, Pineapple Peach.
3. Print both lists
4. Now create a new EMPTY list and call it "fruits_that_are_colours"
5. Iterate (using a for loop) through the first list, and check whether it is in the second list. if it
is, add it to the third list with append()
6. Now print the list of fruits that are colours.
Done.
For a little extra challenge (optional), make use of functions to make the code slicker. Try to keep
your main code as only calls to functions.
Take note that lists created INSIDE functions will not "exist" outside of the functions unless you
define them as global variables. However, if you define a list outside a function, it can be modified
outside
For even more of a challenge, totally optional...
Make use of list comprehension and timeit to determine the computational advantage by using list
comprehension.
Repeat the exercise making use of tuples
Transcribed Image Text:Title Always all these lists. bla bla always lists... Quick assignment: Lists For this assignment, you must create and make use of lists and master the basic skills in() and append(). 1. Create a new list. The list should be called "colour_list". The list should contain the following items: Red, Blue, Purple, Green, Orange, Beige, Peach. 2. Create another list now, which is called "fruit_list". This list should contain: Apple, Banana, Orange, Prune, Pineapple Peach. 3. Print both lists 4. Now create a new EMPTY list and call it "fruits_that_are_colours" 5. Iterate (using a for loop) through the first list, and check whether it is in the second list. if it is, add it to the third list with append() 6. Now print the list of fruits that are colours. Done. For a little extra challenge (optional), make use of functions to make the code slicker. Try to keep your main code as only calls to functions. Take note that lists created INSIDE functions will not "exist" outside of the functions unless you define them as global variables. However, if you define a list outside a function, it can be modified outside For even more of a challenge, totally optional... Make use of list comprehension and timeit to determine the computational advantage by using list comprehension. Repeat the exercise making use of tuples
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Operations of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education