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 cation identifier
ChemistryMediumHigh School (9–10)Principles Related to Practical Chemistry

A cation identifier

You will write three small functions that use the table of cation tests. One compares two cations, one names the cations that fit your results, and one decides whether the ammonia test is needed.

The idea. Each cation has two rows in the table: the effect of aqueous sodium hydroxide and the effect of aqueous ammonia. A row is a pair: the colour of the ppt. and what happens in excess. A result fits a cation when it equals that cation's row. Some results fit more than one cation, so the function lists every cation that fits.

Your tasks.

  1. Complete same_naoh_result(a, b). It is True when two cations give the same result with sodium hydroxide.
  2. Complete identify(naoh, ammonia). It returns a sorted list of the cations that fit. The ammonia result may be None, which means that the test was not done.
  3. Complete needs_ammonia(a, b). It is True when sodium hydroxide cannot tell the two cations apart, but aqueous ammonia can.

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, call identify(("white", "dissolves")). Which two cations does it name?

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 titration calculatorA ppt. calculator for the halide test →
More onPrinciples Related to Practical Chemistry

Discussion (0)

Log in to join the discussion.

Loading…

More labs on this topic

  1. A ppt. calculator for the halide testEasy
  2. A titration calculatorMedium
  3. An error calculator for apparatusEasy
  4. Purity of Mohr's saltMedium
  5. Titration readingsEasy
All labs on this topic →