Slide 1

Slide 1 text

教 青少年 寫程式 從 Scratch 2.0 到 Python 3.3 Renyuan Lyu 呂仁園 長庚大學,資訊系 1 http://scratch.mit.edu/users/ryTemp2014_001/ https://dl.dropboxusercontent.com/u/33089565/ry2014_thinkcspy/html /_ryTest01.html

Slide 2

Slide 2 text

ryCatStar00,貓咪之星 • http://scratch.mit.edu/projects/20615907/ 2

Slide 3

Slide 3 text

• 主程式流程 3

Slide 4

Slide 4 text

• 畫三角形 • 畫五邊形 • 畫多邊形 • 畫五星形 • 畫貓咪之星 4

Slide 5

Slide 5 text

5

Slide 6

Slide 6 text

rySolveEquation00,解2元1次方程式 • http://scratch.mit.edu/projects/20607239/ 6

Slide 7

Slide 7 text

• 主程式流程 7

Slide 8

Slide 8 text

• 輸入方程式係數 a, b, c, e, f, g 8

Slide 9

Slide 9 text

• 解2元1次方程式演算法,行列式計算。 9

Slide 10

Slide 10 text

10

Slide 11

Slide 11 text

ryArkanoid00,敲磚塊遊戲 11 • http://scratch.mit.edu/projects/20604541/ • http://scratch.mit.edu/projects/17662884/

Slide 12

Slide 12 text

• 球拍 (Paddle)、球 (Tennis Ball) 12

Slide 13

Slide 13 text

• 磚塊 (block) 13

Slide 14

Slide 14 text

• 失敗精靈、勝利精靈 14

Slide 15

Slide 15 text

• Pong with High Score – http://scratch.mit.edu/projects/12778537/ • 由此延伸出去,看看別人如何寫程式。 • http://scratch.mit.edu/projects/12778537/remixes 15

Slide 16

Slide 16 text

16

Slide 17

Slide 17 text

Python 17 • 如何像電腦科學家一樣的思考 – 用 Python 3 來學習 – https://dl.dropboxusercontent.com/u/33089565/r y2014_thinkcspy/html/index.html

Slide 18

Slide 18 text

CPU, RAM, HardDisk • Computer Components – https://www.youtube.com/watch?v=rK3YxmkarIg – In this section you learn a little about the architecture of a computer and some general terms to use when talking about computer programs. This includes: • CPU - Central Processing Unit • RAM - Random Access Memory • Hard Drive - A Persistent Storage Device 18

Slide 19

Slide 19 text

Python程式語言很簡單 19 • https://dl.dropboxusercontent.com/u/330895 65/ry2014_thinkcspy/html/_ryTest01.html • 列出 99 乘法表 • 列出 100 以內的質數 • 求二元一次方程式的解 • 小烏龜

Slide 20

Slide 20 text

Hello, little turtles! 嗨,小烏龜! • https://dl.dropboxusercontent.com/u/330895 65/ry2014_thinkcspy/html/hello_little_turtles .html 20 from turtle import * def main(): mode("logo") speed(10) shape("arrow") pensize(3) circle(66) rt(180) circle(66) pu() lt(90) fd(33) rt(90) ….

Slide 21

Slide 21 text

補充 01 • What is a Computer? • What is a Programming Language? • Hello, world ! – 大多數程式語言的第一支程式 21

Slide 22

Slide 22 text

What is a Computer? • A Computer (電腦,計算機) is composed of – Central Processing Unit (CPU), (中央處理器) – Random Access Memory (RAM), (隨機存取 記憶體) – Input/Output (I/O) devices. (輸入輸出設備) • A screen (螢幕) is an output device. • A mouse (滑鼠) and a keyboard (鍵盤) are input devices. • A hard drive (硬碟) is an I/O device. keyboard 22

Slide 23

Slide 23 text

What is a Programming Language (程式語言)? • 語言是人類互相溝通的工具。 • 華語、英語、日語、西班牙語、、、、 – 自然語言數量 6,000 以上 • 使用人口數: – 華語 > 西班牙語 > 英語 > 日語、、、 • 影響力: – 英語 > { 華語、日語、西班牙語、、、} • 人類與電腦溝通,要透過程式語言 • Assembly, C, C++, Java, Python, Scratch, … – 程式語言數量甚至多過自然語言 • 使用人口數: – {C, C++ , Java }> Python > Scratch …. • 影響力: – {C, C++ , Java }> Python > …. • 容易學習的程度: – Scratch > Python > {C, C++, Java,…} > Assembly 23

Slide 24

Slide 24 text

Hello, world ! 大多數程式語言的第一支程式 #include main() { printf("hello, world"); } public class HelloWorld { public static void main(String [] args) { System.out.println("Hello world!"); } } print(‘Hello, world!’) PRINT "Hello, world!" BASIC C Python 3 Scratch Java 印= print 印 (‘Hello, world !’) 24 JavaScript alert('Hello, world!'); Scratch 中文化 Python 3 中文化 C++ #include int main() { std::cout << "Hello, world!" << std::endl; return 0; }

Slide 25

Slide 25 text

• Assembly language — x86 Windows ; This program displays "Hello, World!" in a windows messagebox and then quits. ; ; Written by Stewart Moss - May 2006 ; ; Assemble using TASM 5.0 and TLINK32 ; ; The output EXE is standard 4096 bytes long. ; It is possible to produce really small windows PE exe files, but that ; is outside of the scope of this demo. .486p .model flat,STDCALL include win32.inc extrn MessageBoxA:PROC extrn ExitProcess:PROC .data HelloWorld db "Hello, world!",0 msgTitle db "Hello world program",0 .code Start: push MB_ICONQUESTION + MB_APPLMODAL + MB_OK push offset msgTitle push offset HelloWorld push 0 call MessageBoxA push 0 call ExitProcess ends end Start 25 蠻可怕的吧! 怪不得嚇跑一堆人。

Slide 26

Slide 26 text

補充 02 • A hands-on introduction to Python for beginning programmers • http://www.pyvideo.org/video/1850/a-hands-on- introduction-to-python-for-beginning-p • http://www.pyvideo.org/video/2559/hands-on-intro-to- python-for-beginning-programmer • Introduction to Python with Jessica McKellar • https://www.youtube.com/watch?v=sAU2l5MKCbI • http://vplayer.oreilly.com/?chapter=http%3A%2F%2Fatom.o reilly.com%2Fatom%2Foreilly%2Fvideos%2F2005177&video _product=urn%3Ax- domain%3Aoreilly.com%3Aproduct%3A9781491902141.VID EO#embedded_player 26

Slide 27

Slide 27 text

Jessica’s 16 min Intro 27

Slide 28

Slide 28 text

28

Slide 29

Slide 29 text

by Renyuan 29

Slide 30

Slide 30 text

30 https://www.dropbox.com/s/yxk299gvcuao6au/教青少年寫程式ex001.py

Slide 31

Slide 31 text

Python 程式範例 31 • 列出 99 乘法表 • 列出 100 以內的質數 • 小烏龜 • 求二元一次方程式的解 • 井字棋, Tic-Tac-Toe https://dl.dropboxusercontent.com/u/330895 65/ry2014_thinkcspy/html/_ryTest01.html

Slide 32

Slide 32 text

更多小烏龜程式 • https://dl.dropboxusercontent.com/u/330895 65/ry2014_thinkcspy/html/_ryTurtle03.html • https://www.dropbox.com/sh/yf62s5vhmg5g5 j5/nkUJ92najk 32