定义一个自动运算x的y次方的function

def power(x=1, y=1):
    if not (isinstance(x, (int, float))
            and isinstance(y, (int, float))): # 判断参数x,y是否是int或float
        print("输入错误")
        return
        # 当x或y不是int或float时,在此终止function
    Zhi = x ** y
    return Zhi

print(power(4, 5.1))

 

posted @ 2017-12-11 16:51  类十三  阅读(230)  评论(0编辑  收藏  举报