Ad
Code
Diff
  • class TemperatureConverter:
        def __init__(self, temp: float): self.temp = temp
        fahrenheit_to_celsius = lambda self: round((self.temp - 32) * (5 / 9), 2)
        celsius_to_fahrenheit = lambda self: round((self.temp * 9 / 5) + 32, 2)
    • class TemperatureConverter:
    • def __init__(self, temp: float):
    • self.celsius = round((temp - 32) * (5 / 9), 2)
    • self.fahrenheit = round((temp * 9 / 5) + 32, 2)
    • def fahrenheit_to_celsius(self) -> float:
    • return self.celsius
    • def celsius_to_fahrenheit(self) -> float:
    • return self.fahrenheit
    • def __init__(self, temp: float): self.temp = temp
    • fahrenheit_to_celsius = lambda self: round((self.temp - 32) * (5 / 9), 2)
    • celsius_to_fahrenheit = lambda self: round((self.temp * 9 / 5) + 32, 2)
Code
Diff
  • is_palindrome = lambda s: (c_s := [*map(str.lower,filter(str.isalpha,[*s]))]) == c_s[::-1] 
    • import re
    • def is_palindrome(s: str) -> bool:
    • s = re.sub('[^a-z]', '', s.lower())
    • return s == s[::-1]
    • is_palindrome = lambda s: (c_s := [*map(str.lower,filter(str.isalpha,[*s]))]) == c_s[::-1]