Since we are on the topic of dictionaries, it is a good time to introduce the concept of a data dictionary:
A data dictionary provides a comprehensive description of each variable stored or referred to in a system. It is not a Python thing, rather it is something that programmers use to document their projects.
Ensure that you are signed into GitHub
Open the assignment: Project 6 - Shopping List
Open lab3.py
Organizing Data: They provide a systematic way to document, understand, and manage the various data elements within a software project.
Enhancing Clarity: By offering detailed descriptions of each data element, they ensure that everyone involved in the project has a clear understanding.
Improving Consistency: They help maintain consistency in data usage and interpretation throughout the project lifecycle.
Facilitating Communication: They serve as a reference tool that aids in communication among team members and between developers and stakeholders.
Supporting Maintenance: A comprehensive data dictionary makes it easier to update, modify, or extend the software in the future.
A data dictionary is typically structured as a table with specific columns. Here's a guide on what each column represents:
Variable: The name of the variable or data field used in the code.
Data Type: The type of data (e.g., integer, string, float) the variable holds.
Format for Display: How the data is formatted when displayed (e.g., date format, number format).
Size in Bytes: The memory size of the data type.
Size for Display: How many characters are displayed, including decimal places if applicable.
Description: A brief description of the variable's purpose or role in the system.
Example: A sample value that the variable might hold.
Validation: Any rules or constraints applied to ensure the data is valid (e.g., range for numbers, format for strings).
The above is a general example. You do not need to include every column. It depends on your project and what you are trying to achieve.
Here we have a Distance Converter program to convert from metric to imperial units:
When either designing or documenting this program a data dictionary could be created which outlines all of the variables used above.
In Lab 3 there is some code to fix. Inspect the following data dictionary and then see if you can fix the code to match.
Pay special attention to the data type, formatting and validation.
2. Press Ctrl + F5 to run the program or open a terminal and type python lab3.py
You should now know how to create and use data dictionaries for documenting your programs.
Let's wrap up this lab by pushing our code to GitHub:
Enter a commit message. E.g. "Lab 3 complete"
Press Commit to main
Press Push origin