Discuss / Python / 计算某个数字的多少次方

计算某个数字的多少次方

Topic source

休耕

#1 Created at ... [Delete] [Delete and Lock User]

1 #! /usr/bin/python3 2 # -- coding:UTF-8 -- 3 4 import math 5 def power(x, n): 6 s = 1 7 while n > 0: 8 n = n - 1 9 s = s * x 10 return s 11 12 a = int(input('请输入x:')) 13 b = int(input('请输入n:')) 14 print (power(a,b))


  • 1

Reply