You will write a small calculator for the compounds of this lesson. It reads a formula such as Na2B4O7, finds its molar mass and the percentage of one element, and then adds the water of a hydrate.
The idea. The formula tells how many atoms of each element are in a unit. The molar mass is the sum of mass times count. A hydrate such as borax has its water added: .
Your tasks.
counts(formula) so that it returns a dictionary of the atoms in a simple formula such as Na2B4O7.molar_mass(formula) so that it uses counts and the table MASS.percent(element, formula) so that it returns the mass percentage of one element.hydrate_mass(formula, water) so that it returns the molar mass of the formula plus that number of water molecules.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…