166k views
5 votes
Select the correct boolean expression for each condition in the function m(x). This function should return "Small" if the value stored in x is divisible by both 3 and 5, "multiple of 5" if divisible only by 5, "multiple of 3" if divisible only by 3, and "Orange" otherwise.

User Afeef
by
5.0k points

1 Answer

4 votes

Answer:

Following are method definition to this question:

def m(x): #defining a method and pass an integer parameter

if x%3 == 0 and x%5 == 0: #defining condition that value is divisible by 3 and 5

return "Small" #return value

elif x%5 == 0: # defining condition if value is divisible by 5 only

return "multiple of 5" #return value

elif x%3 == 0: # defining condition if value is divisible by 3 only

return "multiple of 3" # return value

else: # else block

return "Orange" # return value

z=m(15) #call the method and hold return value in variable x

print(z) #print value of variable x

Output:

Small

Explanation:

In the given method definition a method "m" is defined, that passes the value in its parameter, that is x, inside the method, a conditional statement is used, that check multiple conditions, which are described as follows:

  • In if block, it will check, that value is divisible by both 3 and 5 then, it will return a string value, which is "Small".
  • If the above condition is not true, it will go to elif block, in this block we check the value individually divisible by 5, and 3, then it will return "multiple of 5" and "multiple of 3".
  • If the above condition is not true, it will go to else block, in this block, it will return "Orange".
User Mohammed Nagoor
by
5.2k points