Solution 1

def to_fahrenheit(a_list):
    return [(lambda x: x * 9 / 5.0 + 32)(x) for x in a_list]

Temperature Conversion Using list comprehensions

Write a function that combines list comprehensions and lambdas to transform temperatures given in celsius to fahrenheit.

to_fahrenheit([0, 10, 25, 30, 100]) == [32.0, 50.0, 77.0, 86.0, 212.0]

Test Cases

test to fahrenheit repeated values - Run Test

def test_to_fahrenheit_repeated_values():
    assert to_fahrenheit([0, 10, 10, 100]) == [32.0, 50.0, 50.0, 212.0]

test to fahrenheit empty list - Run Test

def test_to_fahrenheit_empty_list():
    assert to_fahrenheit([]) == []

test to fahrenheit - Run Test

def test_to_fahrenheit():
    assert to_fahrenheit([0, 10, 25, 30, 100]) == [32.0, 50.0, 77.0, 86.0, 212.0]
def to_fahrenheit(a_list): pass