(Check a number) Write a program that prompts the user to enter an integer and checks whether the number is divisible by both 5 and 6, divisible by 5 or 6, or just one of them (but not both). Here is a sample run:
Enter an integer: 10
Is 10 divisible by 5 and 6? False
Is 10 divisible by 5 or 6? True
Is 10 divisible by 5 or 6, but not both? True
SOURCE CODE:
# Enter an integer
a=eval(input("Enter an integer: "))
# Checking the given number is divible by 5 and 6
if a % 5 == 0 and a % 6 == 0:
print("Is" + str(a) + "divisible by 5 and 6?")
print("True")
else:
print("Is" + str(a) + "divisible by 5 and 6?")
print("False")
# Checking the given number is divisble by 5 or 6
if a % 5 == 0 or a % 6 == 0:
print("Is" + str(a) + "divisible by 5 or 6?")
print("True")
else:
print("Is" + str(a) + "divisible by 5 or 6?")
print("False")
# Checkin the given number is divisible by 5 or 6 but not both
if (a % 5 == 0 or a % 6 == 0) and not (a % 5 == 0 and a % 6 == 0):
print("Is" + str(a) + "divisible by 5 or 6, but not both?")
print("True")
else:
print("Is" + str(a) + "divisible by 5 or 6, but not both?")
print("False")
OUTPUT:
Enter an integer: 10
Is 10 divisible by 5 and 6?
False
Is 10 divisible by 5 or 6?
True
Is 10 divisible by 5 or 6, but not both?
True