Define a function called create_pattern_dictionary (colours_list) which takes a list of colour names as a parameter and creates a dictionary containing 9 items by looping through each element in the colours list and creating a corresponding key value item. The function returns a pattern dictionary where the key is the pattern number (an integer in the range 0 - 8 inclusive) and the value is a tuple containing two integers and a colour name. The first integer is a row number (0 - 2 inclusive) and the second number is a column number (0-2) inclusive) For example, the following code fragment: colours ['red', 'green', 'blue', 'aqua', 'brown', 'darkseagreen', 'purple', 'lavender', 'magenta'] pattern_dictionary = create_pattern_dictionary(colours) print (pattern_dictionary) produces: (0: (0, 0, 'red'), 1: (0, 1, 'green'), 2: (0, 2, 'blue'), 3: (1, 0, 'aqua'), 4: (1, 1, 'brown'), 5: (1, 2, 'darkseagreen'), 6: (2, 0, 'purple'), 7: (2, 1, 'lavender'), 8: (2, 2, 'magenta')} For example: Test Result (0, 0, 'red') colours ['red', 'green', 'blue', 'aqua', 'brown', 'darkseagreen', 'purple', 'lavender', 'magenta'] pattern_dictionary create_pattern_dictionary(colours) 1 (0, 1, 'green') for key in sorted (pattern_dictionary.keys()): 2 (0, 2, 'blue') print (key, pattern_dictionary [key]) 3 (1, 0, 'aqua') 4 (1, 1, 'brown') 5 (1, 2, 'darkseagreen') 6 (2, 0, 'purple') 7 (2, 1, 'lavender') 8 (2, 2, 'magenta') colours = ['blanchedalmond', 'darkseagreen', 'orange', 'turquoise', 'blue', 'teal', 'yellow', 'brown', 'gray'] pattern_dictionary = create_pattern_dictionary (colours) print (type(pattern_dictionary [0])) values pattern_dictionary [0] print (type(values[0])) print (type(values[1])) print (type(values[2]))
Define a function called create_pattern_dictionary (colours_list) which takes a list of colour names as a parameter and creates a dictionary containing 9 items by looping through each element in the colours list and creating a corresponding key value item. The function returns a pattern dictionary where the key is the pattern number (an integer in the range 0 - 8 inclusive) and the value is a tuple containing two integers and a colour name. The first integer is a row number (0 - 2 inclusive) and the second number is a column number (0-2) inclusive) For example, the following code fragment: colours ['red', 'green', 'blue', 'aqua', 'brown', 'darkseagreen', 'purple', 'lavender', 'magenta'] pattern_dictionary = create_pattern_dictionary(colours) print (pattern_dictionary) produces: (0: (0, 0, 'red'), 1: (0, 1, 'green'), 2: (0, 2, 'blue'), 3: (1, 0, 'aqua'), 4: (1, 1, 'brown'), 5: (1, 2, 'darkseagreen'), 6: (2, 0, 'purple'), 7: (2, 1, 'lavender'), 8: (2, 2, 'magenta')} For example: Test Result (0, 0, 'red') colours ['red', 'green', 'blue', 'aqua', 'brown', 'darkseagreen', 'purple', 'lavender', 'magenta'] pattern_dictionary create_pattern_dictionary(colours) 1 (0, 1, 'green') for key in sorted (pattern_dictionary.keys()): 2 (0, 2, 'blue') print (key, pattern_dictionary [key]) 3 (1, 0, 'aqua') 4 (1, 1, 'brown') 5 (1, 2, 'darkseagreen') 6 (2, 0, 'purple') 7 (2, 1, 'lavender') 8 (2, 2, 'magenta') colours = ['blanchedalmond', 'darkseagreen', 'orange', 'turquoise', 'blue', 'teal', 'yellow', 'brown', 'gray'] pattern_dictionary = create_pattern_dictionary (colours) print (type(pattern_dictionary [0])) values pattern_dictionary [0] print (type(values[0])) print (type(values[1])) print (type(values[2]))
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
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Knowledge Booster
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
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education