You will write three functions that build the name of an alkane with methyl groups on its chain.
The idea. The word root comes from the length of the chain. Number the chain from both ends and keep the set of locants that is lower at the first difference. Then write the locants, a multiplier (di, tri), the word methyl, and the parent name.
Your tasks.
stem, return the word root for a chain of n carbons.lowest, return the lower set of locants, as a sorted list.name_methyl, return the whole name, such as 2,3-dimethylpentane. With no branches, return the plain alkane name.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…
With Standard, you also open 11 more problems, 2 Python labs and 1 extra course. Everything you have used here stays free, always.