19-4:x的y次方

Chinglin-K


目錄:Dice 程式教學-Python完整版
上一篇:19-3:圓面積與體積
下一篇:19-5:質數判斷


題目

請自訂 madepow(x,y) 函式練習。
設計一個 madepow(x,y) 函式,計算 x 的 y 次方,直到 x=0 為止。

輸入範例:
3
2
4
3
10
2
5
4
6
3
0
輸出範例:
9
64
100
625
216


程式碼

import math def madepow(x,y): return pow(x,y) while True: x=int(input()) if(x==0): break y=int(input()) print(madepow(x,y))

輸出


目錄:Dice 程式教學-Python完整版
上一篇:19-3:圓面積與體積
下一篇:19-5:質數判斷


「盡多少本分,得多少本事」😊