Ad
Code
Diff
  • print("".join([i for i in "hello world"]))
    • print("hello world!")
    • print("".join([i for i in "hello world"]))
Code
Diff
  • def temperature_converter(temp: float, conversion='both') -> float:
        celsius = round((temp - 32) * (5 / 9), 2)
        fahrenheit = round((temp * 9/5) + 32, 2)
        
        conversions = {
            'celsius' : celsius,
            'fahrenheit' : fahrenheit,
            'both' : f"{celsius}c, {fahrenheit}f"
        }
        
        return conversions[conversion]
    • def temperature_converter(temp: float, conversion='both') -> float:
    • convert = {
    • 'celsius' : (celsius := round((temp - 32) * (5 / 9) , 2)),
    • 'fahrenheit' : (fahrenheit := round((temp * 9 / 5) + 32, 2)),
    • 'both' : f"{celsius}c, {fahrenheit}f"
    • celsius = round((temp - 32) * (5 / 9), 2)
    • fahrenheit = round((temp * 9/5) + 32, 2)
    • conversions = {
    • 'celsius' : celsius,
    • 'fahrenheit' : fahrenheit,
    • 'both' : f"{celsius}c, {fahrenheit}f"
    • }
    • return convert[conversion]
    • return conversions[conversion]