You will write three functions that a chemist uses on a mass spectrum. A formula is a dictionary of element symbols and counts, such as {"C": 3, "H": 7, "Cl": 1}.
The idea. The nominal mass adds whole-number masses. The carbon count comes from the M+1 peak. The index of hydrogen deficiency counts rings and π bonds.
Your tasks.
nominal_mass(formula), with C = 12, H = 1, N = 14, O = 16, Cl = 35 and Br = 79.carbons(m, m1). It returns the number of carbon atoms, as a whole number, from the heights of M and M+1.ihd(formula).Run your code once to unlock the 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 join the discussion.
Loading…