Advertisement
TVT618

testdivide.py

Jul 26th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. # Created by GitHackTools
  2. # Twitter @SecureGF
  3. # Google+: google.com/+TVT618
  4. # Fb: fb.com/GitHackTools
  5. def testdivide():
  6.     try:
  7.         n1 = float(input('Enter divide number: '))
  8.         n2 = float(input('Enter number to divide: '))
  9.         if n1 % n2 == 0:
  10.             return ('{} can divide for {}'.format(n1,n2))
  11.         elif  n1 % n2 != 0:
  12.             return ('{} can not divide for {}'.format(n1,n2))
  13.  
  14.     except ValueError:
  15.         return('Must be a number, not a words or empty!')
  16.     except ZeroDivisionError:
  17.         return('The number to divide cannot be 0!')
  18.  
  19. def listdivide():
  20.     try:
  21.         can = []
  22.         n3 = int(input('Enter the start number of array: '))
  23.         n4 = int(input('Enter the end number of array: '))
  24.         n5 = int(input('Enter the number to divide: '))
  25.         for i in range(n3,n4+1):
  26.             if i % n5 == 0:
  27.                 can.append(i)
  28.         print()
  29.         print('The numbers can divide for {} from {} to {} is:'.format(n5,n3,n4))
  30.         return can
  31.        
  32.     except ValueError:
  33.         return('Must be a number, not a words and decimals, or empty!')
  34.     except ZeroDivisionError:
  35.         return('The number to divide cannot be 0!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement