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 →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental 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 Programming
  2. /Python for Science and Maths
  3. /Chemistry by Computer

Chemistry by Computer

Python Programming · High School (11–12) · 2 courses, 20 worked problems, 40 practice questions

Chemistry is full of calculations that repeat: molar masses, moles, concentrations and yields. A short Python program can do them quickly and without slips. In this topic you write functions that read a formula such as H2SO4 and add up its molar mass, find the limiting reagent of a reaction, or work out a concentration after dilution. You also load a table of the elements into pandas, filter it, and plot trends such as atomic radius across a period. The computer does the arithmetic, so you can think about the chemistry.

With practice you will be able to

  • Write a function that finds the molar mass of a compound
  • Find the limiting reagent and the yield of a reaction in code
  • Plot a periodic trend from a table of elements

Lessons

  • Moles and Reactions by ComputerHow can code read the brackets in Ca(OH)₂? Which reactant runs out first?High School (11–12)
  • The Periodic Table as DataWhich elements break the rising trend across a period? How does the radius change?High School (11–12)

Practice questions

Choose an answer, then check it. Each one shows a full explanation.

A quartz grain is silica. What does this print? d = {"Si": 28.09, "O": 16.00}; print(round(d["Si"] + 2 * d["O"], 2))

Potassium permanganate is read by the formula reader. How many pairs does it find? import re; print(len(re.findall(r"([A-Z][a-z]?)(\d*)", "KMnO4")))

In Ba(NO3)2, how many oxygen atoms does a correct formula reader count?

A student's reader gives {'C': 1, 'O': 1, 'Cl': 2} for cobalt chloride. What did the student type?

Iron burns in chlorine. What does this print? rounds = {"Fe": 0.45, "Cl2": 0.35}; print(min(rounds, key=rounds.get))

In 2Al+3Cl2→2AlCl32\text{Al} + 3\text{Cl}_2 \rightarrow 2\text{AlCl}_32Al+3Cl2​→2AlCl3​, there are 333 mol of aluminium and 333 mol of chlorine. Which is limiting?

A factory's yield function is called. What does it print? def pct(actual, theory):; return round(100 * actual / theory, 1); print(pct(42, 48))

Copper sulphate solution, 80 mL at 0.35 mol/L: what does this print? print(0.35 * 80 / 1000)

How many mL of a 4 mol/L4\ \text{mol/L}4 mol/L stock make 400 mL400\ \text{mL}400 mL of a 0.6 mol/L0.6\ \text{mol/L}0.6 mol/L solution?

A titration function is called as end_point(0.1, 20), but it is defined as def end_point(acid_M, acid_mL, base_M, ratio=1). What happens?

All 40 practice questions on Chemistry by Computer →

Worked problems

Each one has a hint, the key idea and a full worked solution.

  • Washing soda is sodium carbonate, Na2CO3…Easy
  • Phosgene is COCl2, and cobalt chloride is CoCl2…Medium
  • Ammonium sulphate, (NH4)2SO4, is a fertiliser…Medium
  • Magnesium burns: 2Mg + O₂ → 2MgO. A jar holds 6.0 g of oxygen, and 6.0 g of magnesium ribbon burns…Easy
  • Rahul's function prints the wrong limiting reagent for N₂ + 3H₂ → 2NH₃ with 2.0 mol of nitrogen and…Medium
  • A lime kiln heats limestone: CaCO₃ → CaO + CO₂…Medium
  • Zinc reacts with excess hydrochloric acid: Zn + 2HCl → ZnCl₂ + H₂…Hard
  • Oxalic acid crystals, H₂C₂O₄ · 2H₂O, have a molar mass of 126.07 g/mol…Easy
  • Two bottles of sodium chloride solution are poured together: 200 mL at 0.5 mol/L and 300 mL at 0.2…Medium
  • 25 mL of 0.05 mol/L sulphuric acid is titrated with 0.1 mol/L sodium hydroxide: H₂SO₄ + 2NaOH →…Hard
  • Of the first 36 elements, the halogens are fluorine (64 pm), chlorine (99 pm) and bromine (114 pm)…Easy
  • The first ionisation enthalpies of lithium, sodium and potassium are 520, 496 and 419 kJ/mol…Medium

All 20 worked problems on Chemistry by Computer →

Python labs

  • A formula reader
  • A limiting reagent function
  • Filtering the elements
  • Where the rise breaks

Related topics

  • Python for Science and Maths
  • NumPy Arrays
  • Graphs with matplotlib
  • Solving Equations
  • Calculus by Computer
  • Simulation and Randomness
  • Data Analysis with pandas
  • Biology by Computer
  • Trigonometry and Waves by Computer