Advertisement
sdckey

3s and 5s

Jun 4th, 2020
1,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  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.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement