Microsoft Word - ACG chapter00c-3ed.docx

Similar documents
CC213

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2

数据结构与算法 - Python基础

WWW PHP

投影片 1

CHAPTER VC#

C/C++程序设计 - 字符串与格式化输入/输出

ii Vue Bootstrap 4 ES 6 Vue Vue Bootstrap 4 ES 6 Vue 2 vue html vue html vue Vue HTML 5 CSS ES 6 HTML 5 CSS Visual Studio Code h

02

<4D F736F F F696E74202D20312EB9FEB6FBB1F5B9A4D2B5B4F3D1A7D5E7C1BCA3BAC3E6CFF2D1D0BEBFC9FAB8B4CAD4B5C4BDE1B9B9BBAFC3E6CAD4BFBCBACBCCBDCBF7D3EBCAB5BCF92E BBCE6C8DDC4A3CABD5D>

Microsoft Word - PHP7Ch01.docx

, 即 使 是 在 昏 暗 的 灯 光 下, 她 仍 然 可 以 那 么 耀 眼 我 没 有 地 方 去, 你 会 带 着 我 么 杜 晗 像 是 在 嘲 笑 一 般, 嘴 角 的 一 抹 冷 笑 有 着 不 适 合 这 个 年 龄 的 冷 酷 和 无 情, 看 着 江 华 的 眼 神 毫 无 温

C/C++ - 字符输入输出和字符确认

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp

AL-M200 Series

Learn_Perl 3-02.pdf

C

0020 湖 北 美 术 学 院 戚 雪 雯 书 籍 遇 戴 萌 田 智 文 郭 岚 0021 湖 北 美 术 学 院 胡 星 书 籍 少 年 迈 尔 斯 的 海 戴 萌 田 智 文 郭 岚 0022 湖 北 美 术 学 院 曹 梦 萦 书 籍 古 琴 弹 奏 经 典 三 十 首 戴 萌 田 智 文

WWW PHP Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2

第一章

C/C++ - 字符串与字符串函数

Windows XP

科学计算的语言-FORTRAN95

epub83-1

Microsoft Word - 苹果脚本跟我学.doc

Microsoft Word - 2AF63內文.doc

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

硕士论文正文

Microsoft Word 甘阳.doc

PowerPoint プレゼンテーション

Untitiled

C/C++ 语言 - 循环

sktl00007_read.pdf

Microsoft Word 電腦軟體設計.doc

TPM BIOS Infineon TPM Smart TPM Infineon TPM Smart TPM TPM Smart TPM TPM Advanced Mode...8

C/C++语言 - 运算符、表达式和语句

A Preliminary Implementation of Linux Kernel Virus and Process Hiding

電機工程系認可證照清單 /7/1

C/C++ - 函数

第 15 章 程 式 編 写 語 言 15.1 程 式 編 写 語 言 的 角 色 程 式 編 寫 語 言 是 程 式 編 寫 員 與 電 腦 溝 通 的 界 面 語 法 是 一 組 規 則 讓 程 式 編 寫 員 將 字 詞 集 合 起 來 電 腦 是 處 理 位 元 和 字 節 的 機 器, 與

中國民國第54屆中小學科學展覽會


書本介紹

信息管理专业Python教程

國立中山大學學位論文典藏.PDF

untitled

jsp

2/80 2

CC213

關於本書 Part 3 CSS XHTML Ajax Part 4 HTML 5 API JavaScript HTML 5 API Canvas API ( ) Video/Audio API ( ) Drag and Drop API ( ) Geolocation API ( ) Part 5

前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii

目 录 第 一 部 分 档 案 局 概 况 一 主 要 职 责 二 部 门 决 算 单 位 构 成 第 二 部 分 档 案 局 2016 年 度 部 门 预 算 表 一 2016 年 度 市 级 部 门 收 支 预 算 总 表 二 2016 年 度 市 级 部 门 支 出 预 算 表 三 2016

2015 年 度 收 入 支 出 决 算 总 表 单 位 名 称 : 北 京 市 朝 阳 区 卫 生 局 单 位 : 万 元 收 入 支 出 项 目 决 算 数 项 目 ( 按 功 能 分 类 ) 决 算 数 一 财 政 拨 款 一 一 般 公 共 服 务 支 出 二

2 2 3 DLight CPU I/O DLight Oracle Solaris (DTrace) C/C++ Solaris DLight DTrace DLight DLight DLight C C++ Fortran CPU I/O DLight AM

A9RF716.tmp

Microsoft PowerPoint - OPVB1基本VB.ppt

ebook

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

IP505SM_manual_cn.doc

( )

Eclipse C C++, or

幻灯片 1

Computer Architecture

全国计算机技术与软件专业技术资格(水平)考试

高中英文科教師甄試心得

The golden pins of the PCI card can be oxidized after months or years

uestion ox 初五等合1題庫 Multiple Choice uestion 98年特種考試地方政府公務人員考試試題 1 公務人員請假規則是依據何法律授權所定之 ()公務人員任用法 ()公務員服務法 (C)公務人員俸給法 (D)公務人員保障法 解析 公務員服務法第12條 公務員除因婚喪 疾病


D C 93 2

untitled

<4D F736F F D20AE61AC462DBFAFADB9AD70B565BB50BB73A740B1D0AED7>

“百企入校——广西青年企业家协会高校

C/C++ - 文件IO

- June 意 味 上 梁 不 正 下 梁 歪 地 动 辄 失 去 理 性 而 对 部 下 狂 吠 给 我 滚, 毛 也 曾 因 被 吵 醒 而 对 哨 兵 猛 吼 老 子 揍 你! 并 罚 站 254) 和 大 红 灯 笼 高 高 挂 成 叠 影 的 一 是 太 太 被 老 爷 惯 坏 而 任

創 作 動 機 因 未 成 年 懷 孕 的 案 例 從 國 中 時 期 就 在 身 邊 屢 屢 發 生, 這 意 外 中 的 小 生 命 會 讓 一 個 人 或 說 是 一 對 父 母 的 人 生 產 生 劇 烈 衝 擊, 先 不 談 是 否 成 全 生 命 的 誕 生, 往 往 就 在 社 會 倫

5B_sasaki.pdf

mvc

第7章-并行计算.ppt

untitled

<B2C4A451A454A9A1A578A55FA4E5BEC7BCFAA740AB7EB6B02DA5FEA4E52E706466>

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM

Microsoft Word - C-pgm-ws2010.doc

提 示 : 关 于 材 料 与 测 试 网 用 户 手 册 的 声 明 本 用 户 手 册 受 中 华 人 民 共 和 国 版 权 法 保 护, 未 经 材 料 与 测 试 书 面 许 可, 任 何 人 不 得 拷 贝 转 载 复 印 或 以 其 他 任 何 方 式 分 发 本 手 册 及 其 任

LOVE IS OVER LOVE LOVE LOVE LOVE IS EVERYTHING LOVE LOVE LOVE LOVER'S QUEEN LYDIA MAYBE TOMORROW MEN'S TALK MY DEAR MY FRIEND MY OH MY MY SUMMER DREAM

Microsoft Word - template.doc

Sophos Central 快速安裝手冊

30 ml polystyrene 4 mm ph 0.1 mg blender M -cm D. pulex D. magna 20 L 2 20

Microsoft Word - Datastream5.1_使用說明201110

準 備 第 1~2 週 服 務 第 3~15 週 反 省 第 16~17 週 慶 賀 第 18 週 六 合 作 機 構 協 力 單 位 合 作 協 議 書 : 已 簽 及 附 影 本 乙 份 未 簽, 核 准 之 後 補 送 機 構 名 稱 / 聯 絡 人 台 中 市 青 年 志 工 中 心 財 團

Java 程式設計入門

untitled

jsj0.nps

Untitled-2.indd

Excel VBA Excel Visual Basic for Application

59 1 CSpace 2 CSpace CSpace URL CSpace 1 CSpace URL 2 Lucene 3 ID 4 ID Web 1. 2 CSpace LireSolr 3 LireSolr 3 Web LireSolr ID

Chapter 1 選 用 好 的 燜 燒 罐 選 用 好 的 燜 燒 罐 是 做 好 燜 燒 罐 料 理 最 重 要 的 步 驟, 除 了 須 注 意 使 用 的 材 質 是 否 符 合 食 器 使 用 標 準, 也 須 注 意 燜 燒 罐 的 保 溫 效 果, 才 能 安 心 享 用 燜 燒 罐

Microsoft Word - 8. 以通俗之教化民成俗:晚明经学家郝敬《圣谕俗讲》.doc

Microsoft PowerPoint - Lecture7II.ppt

终端安全2

终端安全10

Transcription:

Python 好好玩, 趣學電玩遊戲程式設計 Python Python BASIC Java JavaScript PHP C++ BASIC Python Python Python Xbox PlayStation Nintendo - 2 -

簡介 : 互動式 Python Shell : 編寫程式 Python File editor : 猜數字 : 腦筋急轉彎 : 龍域 ( ) : 使用 : 使用流程圖設計 遊戲 Hangman : 編寫 猜單字遊戲的程式碼 Chapter 7 : 擴充 猜單字遊戲 Python : 井字棋遊戲程式 OX tic-tac-toe - 3 -

Python 好好玩, 趣學電玩遊戲程式設計 : 推理遊戲 Bagels : 笛卡兒座標系統 : 聲納尋寶遊戲 : 凱撒密碼 ( ) : 黑白棋 : 黑白棋人工智慧模擬 Chapter15 AI : 繪製圖案 Python pygame : 動畫 pygame : 碰撞偵測 2D : 使用聲音和影像 : 使用了聲音和影像的 遊戲 17 20 Dodger - 4 -

1 Shell Python Shell 運算子 整數與浮點數 值 表示式 語法錯誤 把值儲存到變數中

Python 好好玩 - 趣學電玩遊戲程式設計 IDLE IDLE Python Shell Python Shell Shell >>> 2 + 2 Enter Return 1-1 Shell 4 1-1 Shell 2 + 2 + 2 4 1-1 Python 1-1 運算子 + - * / 運算 加法減法乘法除法 - * / Python - 12 -

第 1 章互動式 Shell Integers Ints 4 99 0 Floating-point numbers floats 3.5 42.1 5.0 Python 5 5.0 values Shell 2 2 + 2 expressions 1-2 運算子 值 2 + 2 值 表示式 1-2 Shell Enter >>> 2+2+2+2+2 10 >>> 8*6 48 >>> 10-5+6 11 >>> 2 + 2 4 2 + 2 Python Shell >>> - 13 -

Python 好好玩 - 趣學電玩遊戲程式設計 10 + 5 15 10 + 5 10 + 3 + 2 15 Python 1 + 2 * 3 + 4 11 13 2 * 3 (1 + 2 ) * (3 + 4) 21 (1 + 2) (3 + 4) 15 15 8 * 3 / 2 + 2 + 7-9 12.0 Shell Shell - 14 -

第 1 章互動式 Shell >>> 8 * 3 / 2 + 2 + 7-9 12.0 / 24 / 2 12.0 12.0 + 2 14.0 Shell 5 + Enter >>> 5 + SyntaxError: invalid syntax 5 + + 前與後 SyntaxError Python Shell >>> 變數 指定陳述句 assignment statement = Shell >>> spam = 15 >>> spam 15 1-3 - 15 -

Python 好好玩 - 趣學電玩遊戲程式設計 15 1-3 Enter Python >>> expressions 陳述句 statements Shell spam = 15 Enter spam = 10 + 5 spam = 10 + 7-2 15 15 spam 東西 stuff spam eggs bacon Python Shell Enter >>> spam = 15 >>> spam 15 spam spam 15 Shell - 16 -

第 1 章互動式 Shell >>> spam = 15 >>> spam + 5 20 15 spam spam + 5 15 + 5 spam + 5 Python NameError >>> spam = 15 >>> spma Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> spma NameError: name 'spma' is not defined spam spma Shell >>> spam = 15 >>> spam + 5 20 >>> spam = 3 >>> spam + 5 8 spam + 5 20 spam 15 spam = 3 15 3 spam 3 spam + 5 8 1-4 - 17 -

Python 好好玩 - 趣學電玩遊戲程式設計 3 15 1-4 spam 15 3 spam spam >>> spam = 15 >>> spam = spam + 5 20 spam = spam + 5 spam 5 spam spam 5 Shell >>> spam = 15 >>> spam = spam + 5 >>> spam = spam + 5 >>> spam = spam + 5 >>> spam 30 spam 15 spam + 5 spam 20 3 spam 30 eggs bacon - 18 -

第 1 章互動式 Shell >>> bacon = 10 >>> eggs = 15 bacon 10 eggs 15 1-5 15 10 1-5 bacon eggs spam = bacon + eggs Shell spam >>> bacon = 10 >>> eggs = 15 >>> spam = bacon + eggs >>> spam 25 spam 25 bacon eggs 10 + 15 spam 25 bacon + eggs spam = bacon + eggs 25 spam bacon eggs spam - 19 -

Python 好好玩 - 趣學電玩遊戲程式設計 Python Python 2 5 + - Python Python Python - 20 -

2 Python Hello World! 字串 字串的連接 資料型別 ( 如字串或整數型別 ) 使用 File Editor 來編寫程式

Python 好好玩 - 趣學電玩遊戲程式設計 在 IDLE 中儲存和執行程式 執行的流程 注釋 print() 函式 input() 函式 區分大小寫 Python 字串 strings ' Shell >>> spam = 'hello' Python Shell spam spam Python 'hello' >>> spam = 'hello' >>> spam 'hello' 'hello' 'Hi there!' 'KITTENS' '7 apples, 14 oranges, 3 lemons' 'Anything not pertaining to elephants is irrelephant.' 'A long time ago, in a galaxy far, far away...' 'O*&#wY%*&OCfsdYO*&gfC% YO*& % 3yc8r2' - 22 -

第 2 章編寫程式 + 字串連接 string concatenation Shell 'Hello' + 'World!' >>> 'Hello' + 'World!' 'HelloWorld!' 'HelloWorld!' >>> 'Hello ' + 'World!' 'Hello World!' + 資料型別 data type 'Hello' 5 Python + IDLE Shell IDLE File Editor Shell File New File 2-1 - 23 -

Python 好好玩 - 趣學電玩遊戲程式設計 2-1 Shell File Editor Shell >>> File Editor Hell World Hello World! 請確認您所安裝的是 Python 3 而不是 Python 2! File Editor 2-2 1 Ln: 1 0 Col: 0 2-2 File Editor - 24 -

第 2 章編寫程式 File Editor 原始程式碼 source code Python hello.py 1. # This program says hello and asks for my name. 2. print('hello world!') 3. print('what is your name?') 4. myname = input() 5. print('it is good to meet you, ' + myname) IDLE File Editor 2-3 2-3 File Editor IDLE File Save As Ctrl-S 2-4 hello.py 存檔 IDLE File Open hello.py 開啟舊檔 hello.py File Editor - 25 -

Python 好好玩 - 趣學電玩遊戲程式設計 2-4 File Editor Run Run Module F5 Shell Hello world! 2-5 2-5 hello.py Shell - 26 -

第 2 章編寫程式 Enter F5 https://inventwithpython.com/diff/#diff Compare 2-6 2-6 https://inventwithpython.com/diff/#diff NameError Python 2 Python 3 Hello world! What is your name? Albert Traceback (most recent call last): File "C:/Python26/test1.py", line 4, in <module> myname = input() File "<string>", line 1, in <module> NameError: name 'Albert' is not defined Python 3.4-27 -

Python 好好玩 - 趣學電玩遊戲程式設計 Python Python Python 執行 execution Python Hello World comment 1. # This program says hello and asks for my name. # Python Hello World 函式 function Python Python Hello World print() input() 函式呼叫 function call Python print() print() - 28 -

第 2 章編寫程式 print() Hello World 2 3 print() 2. print('hello world!') 3. print('what is your name?') 引數 argument 2 print() 'Hello world!' 3 print() 'What is your name?' 傳 passing Input() 4 input() myname 4. myname = input() input() 返回值 return value input() Albert input() 'Albert' 'Albert' myname Hello World print() 5. print('it is good to meet you, ' + myname) print() 'It is good to meet you, ' + myname Python - 29 -

Python 好好玩 - 趣學電玩遊戲程式設計 'Albert' myname print('it is good to meet you, ' + myname) print('it is good to meet you, ' + 'Albert') print('it is good to meet you, Albert') Python myname Hello world! What is your name? Carolyn It is good to meet you, Carolyn Hello world! What is your name? poop It is good to meet you, poop - 30 -

第 2 章編寫程式 myname abrahamlincoln name Python 1 東西 Stuff Shell spam eggs bacon spam SPAM Spam spam Python whatihadforbreakfastthismorning whatihadforbreakfastthismorning 駝峰式 (camel case) breakfast foodthismorning whatihadforbreakfastthismorning Python - 31 -

Python 好好玩 - 趣學電玩遊戲程式設計 input() print() + Python Python 3-32 -