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 repeat unit calculator
ChemistryMediumHigh School (9–10)Carbon and Its Compounds › Reactions and Uses of Carbon Compounds

A repeat unit calculator

You will write four functions for the lesson on addition polymers. One finds the relative formula mass of a repeat unit from the four groups on its two carbon atoms. One finds the mass of a chain. One finds the number of repeat units in a chain. One finds the percentage of a group in the polymer.

The idea. The repeat unit has two carbon atoms, with a relative mass of 242424, and four groups. The groups are "H" (1), "CH3" (15), "F" (19) and "Cl" (35.5). PVC has the groups ["H", "H", "H", "Cl"].

Your tasks.

  1. Complete repeat_unit_mr(groups).
  2. Complete chain_mr(unit_mr, n).
  3. Complete units_in_chain(chain_mass, unit_mr), which gives a whole number.
  4. Complete percent_of(group, groups), which gives the percentage by mass of that group in the repeat unit.

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 repeat_unit_mr(["H", "H", "H", "CH3"]). Which polymer is it?

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 carbon budgetA condensation polymer calculator →
More onCarbon and Its Compounds › Reactions and Uses of Carbon Compounds

Discussion (0)

Log in to join the discussion.

Loading…

More labs on this topic

  1. A condensation polymer calculatorMedium
  2. Soap in hard waterMedium
  3. Which flame will it give?Easy
All labs on this topic →