Ad
Code
Diff
  • def is_even(x):
        return True if divmod(x,2)[1] == 0 else False
    
    • def is_even(x):
    • return x & 1 == 0
    • return True if divmod(x,2)[1] == 0 else False
Code
Diff
  • def even_or_odd(number):
        match (number/2 == round(number/2)):
            case 1:
                return 'Even'
            case 0:
                return 'Odd'
        
    • def even_or_odd(number):
    • match (number % 2):
    • case 0:
    • return 'Even'
    • match (number/2 == round(number/2)):
    • case 1:
    • return 'Even'
    • case 0:
    • return 'Odd'
Code
Diff
  • def is_even(x):
        return (x/2 == round(x/2))
    
    • def is_even(x):
    • return x % 2 == 0
    • return (x/2 == round(x/2))