编写函数caculation(x,y)
求: 输入x,y,(均为整型)
判断x是否是y的倍数,返回值是True或者False
可以这样写:
def caculation(x, y):
if y % x == 0:
return True
else:
return False
其中,%
表示取模运算符,即求余数。如果 y
能够被 x
整除,则返回 True
,否则返回 False
。
def caculation(x,y):
return x % y == 0