In: Computer Science
def warmer_year(temps_then: List[int], temps_now: List[int])
-> List[str]:
"""Return a list of strings representing whether this year's
temperatures from temps_now are warmer than past temperatures
in temps_then. The resulting list should contain "Warmer" at
the
indexes where this year's temperature is warmer, and "Not
Warmer"
at the indexes where the past year was warmer, or there is a
tie.
Precondition: len(temps_then) == len(temps_now)
>>> warmer_year([10], [11])
['Warmer']
>>> warmer_year([26, 27, 27, 28], [25, 28, 27, 30])
['Not Warmer', 'Warmer', 'Not Warmer', 'Warmer']
"""
## complete the function here
from typing import * def warmer_year(temps_then: List[int], temps_now: List[int]) -> List[str]: """Return a list of strings representing whether this year's temperatures from temps_now are warmer than past temperatures in temps_then. The resulting list should contain "Warmer" at the indexes where this year's temperature is warmer, and "Not Warmer" at the indexes where the past year was warmer, or there is a tie. Precondition: len(temps_then) == len(temps_now) >>> warmer_year([10], [11]) ['Warmer'] >>> warmer_year([26, 27, 27, 28], [25, 28, 27, 30]) ['Not Warmer', 'Warmer', 'Not Warmer', 'Warmer'] """ result = [] for i in range(len(temps_now)): if temps_now[i] > temps_then[i]: result.append('Warmer') else: result.append('Not Warmer') return result # Testing the function here. ignore/remove the code below if not required print(warmer_year([10], [11])) print(warmer_year([26, 27, 27, 28], [25, 28, 27, 30]))