Skip to content

Instantly share code, notes, and snippets.

@pinkpretty
Created September 19, 2016 09:37
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 pinkpretty/ffd1cbceb82e1ebaf87761e07ef6644a to your computer and use it in GitHub Desktop.
Save pinkpretty/ffd1cbceb82e1ebaf87761e07ef6644a to your computer and use it in GitHub Desktop.
'''
This is the 2nd exercise from http://www.practicepython.org/exercises/
'''
'''
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.
'''
number = int(input("Enter number to find odd or even"))
if(number % 2 == 0):
if(number % 4 == 0):
print ("The number is even number and divisible by 4")
else:
print("The number is even number but cannot be divisible by 4")
else:
print("The number is odd number")
# To check a number is divisible by other
num1, num2 = input("enter two numbers separted by space").split()
num1 = int(num1)
num2 = int(num2)
if(num1 % num2 == 0):
print("The number1 can be evenly divided by number1")
else:
print("the number1 cannot be evenly divided by number2")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment