I want to compare 2 dictionaries only if they meet one of two conditions: either they are equivalent or (more likely) they complement each other in a certain way described below. Do evaluate this, I take values from 2 dictionaries, multiply them together, and run them by a True/False statement. This is my function:
def permissible(dict1,dict2):
a = dict1['conv_factor']
b = dict2['conv_factor']
return a*b == 1.0 or dict1 == dict2
However, when I execute the function, it comes up False, even when mathematically it comes up as True.
source_dict = {'mm': 1, 'cm': 10, 'm': 1000, 'km': 1000000, 'conv_factor': 0.03937007874015748}
dest_dict = {'in': 1, 'ft': 12, 'yd': 36, 'mi': 63360, 'conv_factor': 25.4}
>>>print(permissible(source_dict,dest_dict))
>>>False
The multiplication of a x b evaluates to (1/25.4) x 25.4, which equals 1.0. When I have python print a x b, it returns 1.0. So I am not sure why I can't get the boolean statement to return true.