Definitely, you should convert internally to a single measurement unit and convert at input and at output.
It is even more important in python than in other as it is dynamically typed - you cannot explicitly declare what type do a function use or return. Consider an example:
def get_sodium_for_bread(quantity_of_bread):
...
return quantity_of_sodium
You cannot explicitly define type of quantity_...
variable like in C (miligrams_t get_sodium(slices_t bread)
). If you use different units you will get lost very quickly.
It would be the simpliest if you used a single unit for everything if possible, e.g. grams
food_props_per_gram = {
'bread': {'sodum': 0.000012},
'milk': {'sodium': 0.00032}
}
units_to_grams = {
'slice': 100.0,
'cup': '250.0'
}