Skip to content

Instantly share code, notes, and snippets.

@jmangrad
Created May 7, 2020 02:02
Show Gist options
  • Save jmangrad/60db03c9df41fd2917dceb19bf106b87 to your computer and use it in GitHub Desktop.
Save jmangrad/60db03c9df41fd2917dceb19bf106b87 to your computer and use it in GitHub Desktop.
Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. Hint: how does
an even / odd number react differently when divided by 2?
Extras:
1. If the number is a multiple of 4, print out a different message.
2. Ask the user for two numbers: one number to check (call it num) and one number to divide by (check). If check divides evenly into num, tell that to the user. If not, print a different appropriate message.
#My Answer:
number = int(input("Enter a number: "))
if number%2 == 0:
print("It's even")
else:
print("It's odd")
#extra part 1
if number % 4 == 0:
print("It's divisible by four")
else:
print("It's not divisible by 4")
#extra part 2
num = int(input("Enter a number: "))
check = int(input("Enter a second number"))
if num % check == 0:
print("check divides into num evenly")
else:
print("check doesn't divide into num evenly")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment