本書分為12個單元,通過科學、合理的結構,以親切的筆調、活潑的對話介紹了Python編程的相關知識。用有趣的例子,借助可愛的漫畫生動形象地介紹了包括變量、輸入輸出語句、循環(huán)語句、列表、對象等編程的基本概念。學習本書的內容,可以幫助孩子掌握計算機的思維方式,而書中可視化和以游戲為主的例子可以激發(fā)孩子的學習興趣,培養(yǎng)其專注力。
本書每單元末尾均設置有“小試牛刀”和“小小總結”板塊,可以拓展讀者的思維,鞏固學習的知識和技能。本書是寫給孩子看的Python編程書,也適合父母、老師、學生,以及想要了解計算機編程基礎知識、學習Python編程技能的未成年人閱讀,同時還可以作為少兒編程的教材參考用書。
賈煒,高級工程師,對多種開發(fā)語言都有深入研究,專注于Python人工智能開發(fā)、數據分析、機器學習等;長期從事青少年STEAM教育培訓工作,有豐富的教育培訓經驗。
單元一 認識 Python 語言 13
1.1 什么是人工智能14
1.2 了解 Python 編程語言17
1.3 Python 與人工智能 18
1.4 編寫 Python 程序19
小試 牛刀26
小小 總結··················································································· 27
單元二 加減乘除樣樣行 ··················································· 29
2.1 加減法運算 ··········································································· 30
2.2 乘法運算·············································································· 34
2.3 除法運算·············································································· 36
2.4 取余運算·············································································· 38
2.5 輸入函數 input ······································································ 39
單元三 判斷與比較 ························································· 45
3.1 關系運算符 ··········································································· 46
3.2 True(真)和 False(假)······················································· 47
3.3 如果……那么……·································································· 49
3.4 如果……那么……否則……······················································ 52
單元四 海龜漫步 ···························································· 57
4.1 畫一條直線 ··········································································· 58
4.2 畫等邊三角形········································································ 60
4.3 畫正方形···············································································61
4.4 畫圓形················································································· 63
4.5 給圖形加點顏色····································································· 65
單元五 琢磨不透的隨機數 ················································ 71
5.1 一個隨機數 ··········································································· 72
5.2 與電腦猜拳··········································································· 75
5.3 隨機漫步·············································································· 79
單元六 永不休止的循環(huán) ··················································· 87
6.1 循環(huán)舉例 ·············································································· 88
6.2 有限循環(huán)·············································································· 89
6.3 無限循環(huán)·············································································· 92
單元七 一個大容器 ························································· 99
單元八 程序也有組織 ·····················································109
8.1 給程序取個名字 ···································································· 110
8.2 函數的參數·········································································· 113
8.3 函數的返回值······································································· 116
單元九 信息的長久保存 ················································· 123
9.1 文件的建立 ··········································································124
9.2 讀取文件內容·······································································125
9.3 向文件寫入內容····································································127
9.4 文件追加內容······································································· 131
單元十 我的零花錢我管理 ···············································139
單元十一 面向對象編程很簡單 ·········································155
11.1 何為面向對象 ······································································156
11.2 如何創(chuàng)建一個類···································································157
11.3 類的屬性與方法···································································158
11.4 對象的創(chuàng)建·········································································160
單元十二 彈球游戲 ························································165
附錄 A Python 的安裝與配置··········································183
附錄 B 專業(yè)詞匯速查表··················································190