Activity 19: Master Python List of Dictionaries Data Structure
GUMAPAS, JANUS CRICO
BSIT - 3RD YEAR
1. DICTIONARIES OF PRODUCTS
The above code shows how to effectively store and retrieve data using lists. A collection of items, in this case dictionaries that represent products, are contained in a list that is constructed with square brackets []. Key-value pairs for product name, price, category, and ID are included in every dictionary. You can use the product's index in the list to get to a certain product. Products[0], for instance, would return the first product. You use the relevant key to access a certain product attribute. Products[0]['name'], for example, would provide you with the first product's name. The code also demonstrates how to use a for loop to go over the list, printing each product's data in a structured way. This illustration demonstrates how lists are useful for managing and organizing data, making it easier to retrieve and process information.
2. DICTIONARIES OF EMPLOYEE
Each dictionary in the list defined by the code represents an employee. Key-value pairs are used in each dictionary to hold employee data, including name, ID, email address, and work title. Employee data can be efficiently organized and retrieved thanks to this structure. For instance, you would use workers[0]['name'] to retrieve the first employee's name. You may quickly analyze and present the data for every employee by iterating through the list of dictionaries.
3. DICTIONARIES OF BOOKS
The code defines a list of dictionaries, where each dictionary represents a Filipino book. Each dictionary contains key-value pairs to store information about the book, such as its title, author, ID, genre, and publication year. This structure allows for efficient organization and retrieval of book data. For example, to access the title of the first book, you would use filipino_books[0]['title']
. By iterating over the list of dictionaries, you can easily process and display the information for each book.
4. DICTIONARIES OF UNIVERSITIES
Each dictionary in the list defined by the code represents an institution. Key-value pairs are used in each dictionary to hold details about the university, including its name, address, ID, and founding year. University data can be efficiently organized and retrieved thanks to this structure. For instance, you would use universities[0]['name'] to retrieve the first university's name. You can quickly analyze and present the data for every university by iterating through the list of dictionaries.
5. DICTIONARIES OF RESTAURANT
A list of dictionaries is defined by the code, and each dictionary stands for a restaurant. The restaurant's name, cuisine type, ID, and location are among the key-value pairs that are stored in each dictionary. Restaurant data can be efficiently organized and retrieved thanks to this structure. For instance, you would use restaurants[0]['name'] to retrieve the first restaurant's name. You can quickly analyze and present the data for every restaurant by iterating through the list of dictionaries.
Computing dictionaries are a flexible data structure that let you store and retrieve information quickly. They are made up of key-value pairs, in which every key has a matching value. You can arrange and retrieve information using this structure according to particular IDs. It is simpler to handle and interact with complex data sets when you use dictionaries to construct well-structured and searchable data representations.
GITHUB REPOSITORY : https://github.com/jnss19/Master-Python-List-of-Dictionaries-Data-Structure-19.git
Subscribe to my newsletter
Read articles from Janus Crico Gumapas directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by