HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Python Labs
  2. /A fertiliser calculator
ChemistryMediumHigh School (9–10)Acids, Bases and Salts › Salts and Their Uses

A fertiliser calculator

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 14×atoms of NMr×100\dfrac{14 \times \text{atoms of N}}{M_r} \times 100Mr​14×atoms of N​×100. The atoms of a compound are given as a dictionary, for example ammonium nitrate is {"N": 2, "H": 4, "O": 3}.

Your tasks.

  1. Complete formula_mass(atoms).
  2. Complete percent_nitrogen(atoms).
  3. Complete fertiliser_for(nitrogen_kg, percent), which gives the mass of fertiliser in kg.
  4. Complete richest(options), which gives the name with the highest percentage of nitrogen.

Run it first, just as it is. The checker at the end prints FAIL for each task. Then do the tasks one at a time, and run the program again after each one. A Hint appears under every check that still fails.

When every line says PASS, add potassium nitrate to OPTIONS. It is {"K": 1, "N": 1, "O": 3}. Does the answer to task 4 change?

StemPy LabContributed by StemPy Lab
python
Loading Python runtime…

A worked solution

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 save
← All Labs
← A water checkerA pollution calculator →
More onAcids, Bases and Salts › Salts and Their Uses

Discussion (0)

Log in to join the discussion.

Loading…

More labs on this topic

  1. Water in crystalsMedium
  2. Gas from baking sodaEasy
  3. A titration with three trialsMedium
  4. The pH of everyday liquidsEasy
  5. Dilute an acidMedium
All labs on this topic →