Answer to Question #329083 in Python for ratul

Question #329083

Write a function called foo_moo that takes a number as an argument and returns the following

statements according to the below mentioned conditions. Then, finally prints the statement in

the function call.

If the number is divisible by 2, it should return "Foo".

If the number is divisible by 3, it should return "Moo".

If the number is divisible by both 2 and 3, it should return "FooMoo".

Otherwise, it returns "Boo".


1
Expert's answer
2022-04-15T16:34:31-0400
def foo_moo(number):
    if (number % 2 == 0) & (number % 3 == 0):
        return "FooMoo"
    elif number % 2 == 0:
        return "Foo"
    elif number % 3 == 0:
        return "Moo"
    else:
        return "Boo"
    
n = int(input("Enter number: "))
print(foo_moo(n))

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