Created
February 5, 2019 22:12
-
-
Save pdbartsch/a66bf05d23f4270e40e8c93f6c86e339 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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