This assignment would test your ability to use dictionaries. In the assignment folder,
there are 3 files in total: a2.py, simulation.py and data.json as mentioned above.
In the data.json file, there is a List of dictionaries, where each dictionary has a format
as shown below. Each dictionary represents a person’s record.
Some points to note:
1. No two users can have the same id.
2. The friend_ids key denotes the IDs of the friends of the user. Note that if a user
with id i is a friend of j, then in the friend_ids list of user i, j will be present and in
the friend_ids list of user j, i will be present. Also, a user cannot be a friend of
himself / herself.
3. The data types of each of the fields is as visible in the data.json and the example
4. If the ongoing field of education is False, only then will the percentage field exist.
If it is true, it means that the person is currently studying in that institute and the
final percentage is not available. Thus, the field will not exist. However, a person
can be studying at multiple institutes at the same time.
5. All strings are treated as case-insensitive during searching and when any string
comparisons are being performed. But, when a string needs to be printed to the
screen, it should be printed in the same case with which it is stored in the
records. Also, when a user gives a string which needs to be added to the records,
the string should be added in the same case with which the user entered it.
“institute”: “ABCD School”,
“institute”: “EFGH Institute”,
“institute”: “IJKL College”,
“friend_ids”: [2, 6]
There is a function read_data_from_file(file_path) in a2.py module. This
function reads the data.json file and loads all of the data into a variable named records.
You have to call this method to get the person records from the data.json file.
After reading the data, you have to implement all the other functions as mentioned. The
functions, shown below, are used for filtering/updating the data based on specific
1. read_data_from_file (The code for this function is already provided)
After implementing all the above functions, you need to simulate an interactive menu
based scenario in the simulation.py module, where you would import the a2.py module
and use all the above given methods.
The general flow of the program looks something like this:
● Greet the user and show them the given queries in a menu based fashion.
● Then, ask them which query they would like to perform. Take a query code as
input from the user. The code can range from 1 to 16, which denote the functions
list as shown above.
● If any query updates the records, then the subsequent queries must work with the
● Corresponding to the given query code and the functionality, ask the inputs from
the user which would be passed as parameters to the respective function call.
For example, if the user inputs query code as 16 which corresponds to the Add
education functionality, you need to ask the below inputs from the user:
i. id (INTEGER): The person id
ii. institute (STRING): The institute name
iii. ongoing (BOOLEAN): The ongoing value representing if the person is
currently enrolled for that education
iv. percentage (FLOAT): The person’s score in percentage, if the person is
not currently enrolled and has been allotted the score for the same.
● Ask the query codes from the user, until the user inputs the query code as -1.