SHARE
TWEET

3s and 5s

sdckey Jun 4th, 2020 1,017 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import argparse
  2.  
  3. def DivisibleByThree(value) :
  4.     return value % 3 == 0
  5.  
  6. def DivisibleByFive(value)  :
  7.     return value % 5 == 0
  8.  
  9. def DivisibleByThreeAndFive(value)   :
  10.     return DivisibleByThree(value) and DivisibleByFive(value)
  11.  
  12. parser = argparse.ArgumentParser(description='Check for 3s and 5s.')
  13. parser.add_argument('integer', type = int, help='the integer to check')
  14.  
  15. args = parser.parse_args()
  16.  
  17. i = args.integer
  18.  
  19. if DivisibleByThreeAndFive(i)  :
  20.     print(i, 'is divisible by 3 and 5.')
  21. elif DivisibleByThree(i)  :
  22.     print(i, 'is divisible by 3.')
  23. elif DivisibleByFive(i)  :
  24.     print(i, 'is divisible by 5.')
  25. else  :
  26.     print(i, 'is not divisible by 3 or 5.')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top