Write a program that prompts the user to enter an integer and determines
whether it is divisible by 5 and 6, whether it is divisible by 5 or 6, and whether
it is divisible by 5 or 6, but not both
def is_div_by_5(x):
return x%5==0
def is_div_by_6(x):
return x%6==0
n=int(input('Please enter an integer: '))
if is_div_by_6(n) and is_div_by_5(n):
print(n, 'is divisible by both 5 and 6')
elif is_div_by_5(n):
print(n, 'is divisible by only 5')
elif is_div_by_6(n):
print(n, 'is divisible by only 6')
else:
print(n, 'is not divisible by 5 or 6')
Comments
Leave a comment