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".
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))
Comments
Leave a comment