You will write four functions for the lesson on fertilisers. One finds the relative formula mass of a compound from the atoms in its formula. One finds the percentage of nitrogen. One finds the mass of a fertiliser that supplies a given mass of nitrogen. One picks the fertiliser with the highest percentage of nitrogen.
The idea. The percentage of nitrogen is . The atoms of a compound are given as a dictionary, for example ammonium nitrate is {"N": 2, "H": 4, "O": 3}.
Your tasks.
formula_mass(atoms).percent_nitrogen(atoms).fertiliser_for(nitrogen_kg, percent), which gives the mass of fertiliser in kg.richest(options), which gives the name with the highest percentage of nitrogen.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…