- A+
所属分类:Python习题
函数pow()
pow(x,y):这个是表示x的y次幂。
pow(x,y,z):这个是表示x的y次幂后除以z的余数。
python递归代码
- 挑错版
- def power(x,y):
- if y == 1:
- return x
- else:
- return x * power(x,y-1)
- print(power(2,3))
想看看这代码,哪些地方错了吗?
- 正确版
- def power(x, y):
- if y:
- return x * power(x, y - 1)
- else:
- return 1
- print(power(2, 0))
2019年10月14日 下午5:37 21楼
为什么还是不能看
2019年11月3日 下午7:02 22楼
我要看
2019年11月16日 下午7:44 23楼
感觉没错
2019年11月16日 下午7:45 24楼
求答案
2020年3月10日 上午11:18 25楼
?是那么
2020年4月3日 下午6:43 26楼
哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
2020年4月10日 下午4:40 27楼
求
2020年11月4日 下午2:25 28楼
看不出来
2022年4月4日 上午10:38 29楼
求解