Ad
Code
Diff
  • def even_or_odd(n):
        return "Even" if n % 2 == 0 else "Odd"
    
    
    • def even_or_odd(n):
    • return "Even" if n & 1 == 0 else "Odd"
    • return "Even" if n % 2 == 0 else "Odd"
Code
Diff
  • def even_or_odd(n):
        return "Even" if n % 2 == 0 else "Odd"
    • def even_or_odd(number):
    • return "Even" if bin(number)[2:][-1]=="0" else "Odd"
    • def even_or_odd(n):
    • return "Even" if n % 2 == 0 else "Odd"
Code
Diff
  • def even_or_odd(n):
        return "Even" if n % 2 == 0 else "Odd"
    • even_or_odd = lambda n: ('EOvdedn')[n & 1::2]
    • def even_or_odd(n):
    • return "Even" if n % 2 == 0 else "Odd"
Code
Diff
  • def even_or_odd(n):
        return "Even" if n % 2 == 0 else "Odd"
    • def even_or_odd(n):
    • if n==0:
    • return "Even"
    • elif n==1 or n==-1:
    • return "Odd"
    • if n<0:
    • return even_or_odd(n+2)
    • return even_or_odd(n-2)
    • return "Even" if n % 2 == 0 else "Odd"
Code
Diff
  • def even_or_odd(n):
        return "Even" if n % 2 == 0 else "Odd"
            
    • def even_or_odd(n):
    • if n==0:
    • return "Even"
    • elif n==1 or n==-1:
    • return "Odd"
    • if n<0:
    • return even_or_odd(n+2)
    • return even_or_odd(n-2)
    • return "Even" if n % 2 == 0 else "Odd"