Python Python https www python orgdownloads Anaconda https

  • Slides: 15
Download presentation

Python程式開發環境 官方版Python https: //www. python. org/downloads Anaconda開發環境 https: //www. anaconda. com/download

Python程式開發環境 官方版Python https: //www. python. org/downloads Anaconda開發環境 https: //www. anaconda. com/download

Python撰寫 具 官方版IDLE Anaconda Jupyter Notebook

Python撰寫 具 官方版IDLE Anaconda Jupyter Notebook

關鍵字 常數 l l l False True None 控制結構 l l l if for

關鍵字 常數 l l l False True None 控制結構 l l l if for … False class finally return None continue for lambda try True def from nonlocal while and del as yield pass raise global elif assert break with or import in not if else except is

流程控制--判斷結構 (Decision Structures) 單向if x=2 y=1 if x > y: z=x-y print("x比y大", z) 雙向if.

流程控制--判斷結構 (Decision Structures) 單向if x=2 y=1 if x > y: z=x-y print("x比y大", z) 雙向if. . . else score = 59 if score >= 60: print("及格!") else: print("不及格!") 多向if. . . else score = 80 if score >= 90: print("優等") elif score < 90 and score >= 80: print("甲等") elif score < 80 and score >= 70: print("乙等") elif score < 70 and score >= 60: print("丙等") else: print("不及格")

流程控制--迴圈結構 (Loop Structures) for var in iterator: statements 1 [else: statements 2] 範例 1:

流程控制--迴圈結構 (Loop Structures) for var in iterator: statements 1 [else: statements 2] 範例 1: for i in range(5): print(i) 範例 2: list 1 = [15, 20, 33, 7, 8] sum = 0 for i in list 1: sum = sum + i print("總和等於", sum)

Python程式範例 # 九九乘法表 result 2 = '' for i in range(2, 10): result 1

Python程式範例 # 九九乘法表 result 2 = '' for i in range(2, 10): result 1 = '' for j in range(2, 10): result 1 = result 1 + str(i) + '*' + str(j) + '=' + str(i * j) + 't' result 2 = result 2 + result 1 + 'n' print(result 2) 2*2=4 2*3=6 2*4=8 2*5=10 2*6=12 2*7=14 2*8=16 2*9=18 3*2=6 3*3=9 3*4=12 3*5=15 3*6=18 3*7=21 3*8=24 3*9=27 4*2=8 4*3=12 4*4=16 4*5=20 4*6=24 4*7=28 4*8=32 4*9=36 5*2=10 5*3=15 5*4=20 5*5=25 5*6=30 5*7=35 5*8=40 5*9=45 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36 6*7=42 6*8=48 6*9=54 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49 7*8=56 7*9=63 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64 8*9=72 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81

參考資料 n Ø Ø n Ø Python安裝程序 官方版:https: //www. youtube. com/watch? v=wq. Rl. KVRUV_k

參考資料 n Ø Ø n Ø Python安裝程序 官方版:https: //www. youtube. com/watch? v=wq. Rl. KVRUV_k Anaconda開發環境:https: //www. youtube. com/watch? v=9 LEwsk 8 d. R 3 o Python程式設計 陳惠貞,「一步到位!Python程式設計」,旗標,2019。