Answer to Question #275647 in Python for mohammed

Question #275647

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


1
Expert's answer
2021-12-04T20:47:38-0500
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')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS