for 迴圈
# for 迴圈
# for 變數 in 字串OR列表
# 要重複執行的程式碼
for what in "JODER":
print(what)
for num in [1,11,2,22,33,44,1]:
print(num)
# for 變數 in range(次數) EX:0~11 (12次)
for num in range(12):
print(num)
for num in [4,5,6,7,8,9,10]:
print(num)
for num in range(4,11):
print(num)
次方函數 pow=(基數,次方數)
pow(3,4)
def power(base_num,pow_num):
result = base_num
for index in range(pow_num-1):
result = result * base_num
return result
print(power(3,4))
def power(base_num,pow_num):
result =1
for index in range(pow_num):
result = result * base_num
return result
print(power(3,4))