Advertisement
ganiyuisholaafeez

Even or Odd function

Feb 19th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. """ This function only tests if an integer argument
  2. is an even number or odd """
  3. # The function is named even_or_odd and it accepts an integer argument
  4. def even_or_odd(number):
  5.  
  6. # The block test for oddity or eveness and it returns the appropriate string
  7.     if number % 2 == 0:
  8.         return "even"
  9.     else:
  10.         return "odd"
  11.  
  12. # Function Invokation
  13. print(even_or_odd(2))
  14. print(even_or_odd(0))
  15. print(even_or_odd(13))
  16. print(even_or_odd(9))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement