exercise_04_mutation_rate_arbitrary
[Basic Programming Lecture Exercise 4] The solution for arbitrary mutation rate classification using a dictionaryNoahHK
python
2 years ago
718 B
12
Indexable
Never
def classify_mutation_rate_arbitrary( snp : float, levels : dict ) -> str: """ Classifies a gene based based on the provided snp count and the provided mutation rate levels Parameters ---------- snp : float The gene's SNP count levels : dict A dictionary mapping the mutation rate levels to the classification, e.g. { 2 : 'highly conserved', 10 : 'conserved', 30 : 'variant' } Returns ------- str The classification of mutation rate """ # Classification as specified in the task description for level, classification in levels.items(): if snp < level: return classification return list( levels.values() )[-1]