I have a dictionary that looks like this:
d_1 = {
"k1":{
"a":0.215,
"b":350
},
"k2":{
"a":1.0125,
"b":1.1802
}
}
I want to create a second dictionary that stores the result of 0.215/1.0125, stored in the a keys of k1 and k2 dictionaries, but I want the value to update in the same fashion that an excel sheets does.
To illustrate this, imagine you have the cell A1 = 0.215 and cell B1 = 1.0125. Then cell C1 would be A1/B1. If you update A1 or B1, the value of C1 is automatically updated.
Is there any way to create a second dictionary d_2 which key stores the result of d_1["k1"]["a"]/d_1["k2"]["a"] and updates the result dynamically, like the excel example? And if its not possible, what is the closest thing I could do to achieve this?
EDIT:
The desired solution I'm looking is something similar to having shallow copies of parts of d_1, like d_1["k1"]["a"]/d_1["k2"]["a"]. I know that if I have two dictionaries and one is the copy of the other, if I change the value of one key-value pair in the first dictionary, the second dictionary should also change. To get a "hard" copy of the first dictionary deepcopy should be used.
Can something like a shallow copy of the dictionary but applying the mathematical operation be done or its not possible?