Define the function number_in_trophic_class(tli3_values, classification) which takes a list of trophic level index values and a trophic classification, returning the number of lakes in that trophic class. For this version of the question you cannot use a list comprehension (or any comprehension) - you will get to use one in the next version of the question. :) Notes: You must include, and use/call your trophic_class function in your submission. Your tropic_class function must work in the same way it did for Question 2. You can assume that classification will always be valid, i.e. it will always be one of the states in the following list: ['Hypertrophic', 'Supertrophic', 'Eutrophic', 'Mesotrophic', 'Oligotrophic', 'Microtrophic', 'Ultra-microtrophic'] For example: Test Result tli3_list_1 = [4.1061, 2.54561, 4.16276, 2.33801, 6.71792, 5.54457, 6.49795, 2.1, 1.2, 1.4, 0.9, 3.8, 3.0] number = number_in_trophic_class(tli3_list_1, 'Microtrophic') print(f'{number} were Microtrophic.') 2 were Microtrophic. tli3_list_1 = [4.1061, 2.54561, 4.16276, 2.33801, 6.71792, 5.54457, 6.49795, 2.1, 1.2, 1.4, 0.9, 3.8, 3.0] number = number_in_trophic_class(tli3_list_1, 'Mesotrophic') print(f"{number} were Mesotrophic.") 2 were Mesotrophic. def trophic_class(trophic_level_index): '''Return the tropic classification indicated by the Trophic Level Index value provided''' if trophic_level_index >=6: return ('Hypertrophic') elif trophic_level_index >=5 and trophic_level_index < 6: return ('Supertrophic') elif trophic_level_index >=4 and trophic_level_index < 5: return ('Eutrophic') elif trophic_level_index >=3 and trophic_level_index < 4: return ('Mesotrophic') elif trophic_level_index >=2 and trophic_level_index < 3: return ('Oligotrophic') elif trophic_level_index >=1 and trophic_level_index < 2: return ('Microtrophic') elif trophic_level_index <1: return ('Ultra-microtrophic')
Define the function number_in_trophic_class(tli3_values, classification) which takes a list of trophic level index values and a trophic classification, returning the number of lakes in that trophic class. For this version of the question you cannot use a list comprehension (or any comprehension) - you will get to use one in the next version of the question. :)
Notes:
- You must include, and use/call your trophic_class function in your submission.
- Your tropic_class function must work in the same way it did for Question 2.
- You can assume that classification will always be valid, i.e. it will always be one of the states in the following list:
- ['Hypertrophic',
'Supertrophic',
'Eutrophic',
'Mesotrophic',
'Oligotrophic',
'Microtrophic',
'Ultra-microtrophic']
- ['Hypertrophic',
For example:
Test | Result |
---|---|
tli3_list_1 = [4.1061, 2.54561, 4.16276, 2.33801, 6.71792, 5.54457, 6.49795, 2.1, 1.2, 1.4, 0.9, 3.8, 3.0] number = number_in_trophic_class(tli3_list_1, 'Microtrophic') print(f'{number} were Microtrophic.') | 2 were Microtrophic. |
tli3_list_1 = [4.1061, 2.54561, 4.16276, 2.33801, 6.71792, 5.54457, 6.49795, 2.1, 1.2, 1.4, 0.9, 3.8, 3.0] number = number_in_trophic_class(tli3_list_1, 'Mesotrophic') print(f"{number} were Mesotrophic.") |
2 were Mesotrophic. |
def trophic_class(trophic_level_index):
'''Return the tropic classification indicated by the Trophic Level Index
value provided'''
if trophic_level_index >=6:
return ('Hypertrophic')
elif trophic_level_index >=5 and trophic_level_index < 6:
return ('Supertrophic')
elif trophic_level_index >=4 and trophic_level_index < 5:
return ('Eutrophic')
elif trophic_level_index >=3 and trophic_level_index < 4:
return ('Mesotrophic')
elif trophic_level_index >=2 and trophic_level_index < 3:
return ('Oligotrophic')
elif trophic_level_index >=1 and trophic_level_index < 2:
return ('Microtrophic')
elif trophic_level_index <1:
return ('Ultra-microtrophic')
Step by step
Solved in 2 steps with 3 images