Skip to content

Instantly share code, notes, and snippets.

@pdbartsch
Created February 5, 2019 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdbartsch/a66bf05d23f4270e40e8c93f6c86e339 to your computer and use it in GitHub Desktop.
Save pdbartsch/a66bf05d23f4270e40e8c93f6c86e339 to your computer and use it in GitHub Desktop.
# https://www.practicepython.org/exercise/2014/02/05/02-odd-or-even.html
# in case floats are input force them to int
num = int(float(input("Please enter a whole number. ")))
check = int(float(input("Please enter another whole number. ")))
# set message depending on if num / check leaves a remainder
if num % check == 0:
message = str(num) + ' can be divided evenly by ' + str(check) + ' and the result is ' + str(int(num/check))
else:
message = str(num) + ' can not be divided evenly by ' + str(check)
# what about by 4
if num % 4 == 0:
print(str(num) + ' is evenly divisible by four.')
# determine even or odd
if num % 2 == 0:
print(str(num) + ' is an even number. \n' + message)
else:
print(str(num) + ' is an odd number. \n' + message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment