SlideShare a Scribd company logo
教 青少年 寫程式
從 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
ryCatStar00,貓咪之星
• http://scratch.mit.edu/projects/20615907/
2
• 主程式流程
3
• 畫三角形
• 畫五邊形
• 畫多邊形
• 畫五星形
• 畫貓咪之星
4
5
rySolveEquation00,解2元1次方程式
• http://scratch.mit.edu/projects/20607239/
6
• 主程式流程
7
• 輸入方程式係數
a, b, c,
e, f, g
8
• 解2元1次方程式演算法,行列式計算。
9
10
ryArkanoid00,敲磚塊遊戲
11
• http://scratch.mit.edu/projects/20604541/
• http://scratch.mit.edu/projects/17662884/
• 球拍 (Paddle)、球 (Tennis Ball)
12
• 磚塊 (block)
13
• 失敗精靈、勝利精靈
14
• Pong with High Score
– http://scratch.mit.edu/projects/12778537/
• 由此延伸出去,看看別人如何寫程式。
• http://scratch.mit.edu/projects/12778537/remixes
15
16
Python
17
• 如何像電腦科學家一樣的思考
– 用 Python 3 來學習
– https://dl.dropboxusercontent.com/u/33089565/r
y2014_thinkcspy/html/index.html
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
Python程式語言很簡單
19
• https://dl.dropboxusercontent.com/u/330895
65/ry2014_thinkcspy/html/_ryTest01.html
• 列出 99 乘法表
• 列出 100 以內的質數
• 求二元一次方程式的解
• 小烏龜
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)
….
補充 01
• What is a Computer?
• What is a Programming Language?
• Hello, world !
– 大多數程式語言的第一支程式
21
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
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
Hello, world !
大多數程式語言的第一支程式
#include <stdio.h>
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 <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
return 0;
}
• 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
蠻可怕的吧!
怪不得嚇跑一堆人。
補充 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=https%3A%2F%2Fptop.only.wip.la%3A443%2Fhttp%2Fatom.o
reilly.com%2Fatom%2Foreilly%2Fvideos%2F2005177&video
_product=urn%3Ax-
domain%3Aoreilly.com%3Aproduct%3A9781491902141.VID
EO#embedded_player
26
Jessica’s 16 min Intro
27
28
by Renyuan
29
30https://www.dropbox.com/s/yxk299gvcuao6au/教青少年寫程式ex001.py
Python 程式範例
31
• 列出 99 乘法表
• 列出 100 以內的質數
• 小烏龜
• 求二元一次方程式的解
• 井字棋, Tic-Tac-Toe
https://dl.dropboxusercontent.com/u/330895
65/ry2014_thinkcspy/html/_ryTest01.html
更多小烏龜程式
• https://dl.dropboxusercontent.com/u/330895
65/ry2014_thinkcspy/html/_ryTurtle03.html
• https://www.dropbox.com/sh/yf62s5vhmg5g5
j5/nkUJ92najk
32

More Related Content

PDF
Learning python in the motion picture industry by will zhou
Will Zhou
 
PDF
Pycontw2013x
weijr
 
PDF
[系列活動] Python 程式語言起步走
台灣資料科學年會
 
PDF
[COSCUP2013] Python, F#, Golang and Friends
weijr
 
PDF
《Python 3.5 技術手冊》第二章草稿
Justin Lin
 
PDF
Python 于 webgame 的应用
勇浩 赖
 
PPT
页游开发中的 Python 组件与模式
勇浩 赖
 
PDF
Android C Library: Bionic 成長計畫
Kito Cheng
 
Learning python in the motion picture industry by will zhou
Will Zhou
 
Pycontw2013x
weijr
 
[系列活動] Python 程式語言起步走
台灣資料科學年會
 
[COSCUP2013] Python, F#, Golang and Friends
weijr
 
《Python 3.5 技術手冊》第二章草稿
Justin Lin
 
Python 于 webgame 的应用
勇浩 赖
 
页游开发中的 Python 组件与模式
勇浩 赖
 
Android C Library: Bionic 成長計畫
Kito Cheng
 

Similar to 教青少年寫程式 (20)

PDF
Scratch2 MOOCS
Chitsai Yeh
 
PDF
Java Jdk6学习笔记[Ppt]
yiditushe
 
PDF
一場與程式設計的邂逅
建宇 陳
 
PDF
給軟體工程師的不廢話 R 語言精要班
台灣資料科學年會
 
PDF
COSCUP 2016 - LLVM 由淺入淺
宗凡 楊
 
PDF
COSCUP2016 - LLVM框架、由淺入淺
hydai
 
PDF
漫談 Source Control Management
Wen-Shih Chao
 
PDF
OpenSCAD Workshop
Justin Lin
 
PPTX
Introduction to corona sdk
馬 萬圳
 
PPTX
[3]投影片 futurewad樹莓派研習會 141204
CAVEDU Education
 
PDF
專業外語(二)ghbhuhhhyggyyggyggggggggg-W04.pdf
MeiMei986041
 
PDF
專業外語(二)hwhwbajwnjsnansjsjsnsnnsnsnsb-W04.pdf
MeiMei986041
 
PPTX
Homework7補充教學
Jessica Hsieh
 
PPTX
DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代
scott liao
 
PPT
Grails敏捷项目开发
Michael Yan
 
PPTX
資訊教育 Ch8簡報
Queifang Chung
 
PDF
20200905_tcn_python_opencv_part1_omnixri
OmniXRI Studio
 
PPTX
從頭打造 C#、.NET 與 ASP.NET Core 開發環境
Will Huang
 
PDF
基于 FRIDA 的全平台逆向分析
CC
 
PPTX
2016/12/10 HourOfCode 主辦心得/計畫 簡報 (by scratch-tw.org)
Yu-Hsien Fang
 
Scratch2 MOOCS
Chitsai Yeh
 
Java Jdk6学习笔记[Ppt]
yiditushe
 
一場與程式設計的邂逅
建宇 陳
 
給軟體工程師的不廢話 R 語言精要班
台灣資料科學年會
 
COSCUP 2016 - LLVM 由淺入淺
宗凡 楊
 
COSCUP2016 - LLVM框架、由淺入淺
hydai
 
漫談 Source Control Management
Wen-Shih Chao
 
OpenSCAD Workshop
Justin Lin
 
Introduction to corona sdk
馬 萬圳
 
[3]投影片 futurewad樹莓派研習會 141204
CAVEDU Education
 
專業外語(二)ghbhuhhhyggyyggyggggggggg-W04.pdf
MeiMei986041
 
專業外語(二)hwhwbajwnjsnansjsjsnsnnsnsnsb-W04.pdf
MeiMei986041
 
Homework7補充教學
Jessica Hsieh
 
DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代
scott liao
 
Grails敏捷项目开发
Michael Yan
 
資訊教育 Ch8簡報
Queifang Chung
 
20200905_tcn_python_opencv_part1_omnixri
OmniXRI Studio
 
從頭打造 C#、.NET 與 ASP.NET Core 開發環境
Will Huang
 
基于 FRIDA 的全平台逆向分析
CC
 
2016/12/10 HourOfCode 主辦心得/計畫 簡報 (by scratch-tw.org)
Yu-Hsien Fang
 
Ad

More from Renyuan Lyu (11)

PDF
Py conjp2019 renyuanlyu_3
Renyuan Lyu
 
PPTX
Py conjp2019 renyuanlyu_3
Renyuan Lyu
 
PDF
Py conjp2019 renyuanlyu_3
Renyuan Lyu
 
PDF
Lightning talk01 docx
Renyuan Lyu
 
PDF
Lightning talk01
Renyuan Lyu
 
PPTX
Pycon JP 2016 ---- Pitch Detection
Renyuan Lyu
 
PPTX
pycon jp 2016 ---- CguTranslate
Renyuan Lyu
 
PDF
pyconjp2015_talk_Translation of Python Program__
Renyuan Lyu
 
PDF
Ry pyconjp2015 turtle
Renyuan Lyu
 
PDF
Ry pyconjp2015 karaoke
Renyuan Lyu
 
PDF
Pycon apac 2014
Renyuan Lyu
 
Py conjp2019 renyuanlyu_3
Renyuan Lyu
 
Py conjp2019 renyuanlyu_3
Renyuan Lyu
 
Py conjp2019 renyuanlyu_3
Renyuan Lyu
 
Lightning talk01 docx
Renyuan Lyu
 
Lightning talk01
Renyuan Lyu
 
Pycon JP 2016 ---- Pitch Detection
Renyuan Lyu
 
pycon jp 2016 ---- CguTranslate
Renyuan Lyu
 
pyconjp2015_talk_Translation of Python Program__
Renyuan Lyu
 
Ry pyconjp2015 turtle
Renyuan Lyu
 
Ry pyconjp2015 karaoke
Renyuan Lyu
 
Pycon apac 2014
Renyuan Lyu
 
Ad

Recently uploaded (20)

PPTX
3分钟读懂密西根大学毕业证U-M毕业证学历认证
keaceh
 
PPTX
3分钟读懂美国东北大学毕业证NEU毕业证学历认证
riecoa
 
PPTX
英国学位证书,UIUC毕业证香槟分校毕业证学历认证UIUC毕业证办
gjgrege
 
PPTX
一比一制作女王大学毕业证QU毕业证学校版本
betrui
 
PPTX
3分钟读懂坎特伯雷大学毕业证UC毕业证学历认证
bohjoj
 
PPTX
3分钟读懂德比大学毕业证Derby毕业证学历认证
juftee
 
PPTX
3分钟读懂北卡罗莱纳大学毕业证UNC毕业证学历认证
hantil
 
PPTX
3分钟读懂利兹三一大学毕业证LeedsTrinity毕业证学历认证
zughog
 
PPTX
英国学位证书,考文垂大学毕业证学历认证Coventry毕业证制做
3of9
 
PPTX
英国学位证书,爱丁堡大学毕业证学历认证Edin毕业证加急办理
3of9
 
PPTX
3分钟读懂莱斯特大学毕业证Leicester毕业证学历认证
zughog
 
PPTX
英国学位证书,拉夫堡大学毕业证学历认证LU毕业证买
3of9
 
PPTX
3分钟读懂德蒙福特大学毕业证DMU毕业证学历认证
juftee
 
PPTX
一比一制作威尔士大学毕业证UWIC毕业证学校版本
nihwuk
 
PPTX
3分钟读懂创意艺术大学毕业证UCA毕业证学历认证
juftee
 
PPTX
一比一制作斯旺西大学毕业证Swansea毕业证学校版本
nihwuk
 
PPTX
3分钟读懂普渡大学毕业证Purdue毕业证学历认证
dukfis
 
PPTX
美国学位证书,密歇根理工大学毕业证学历认证MTU毕业证加急购买
ewzt6ecilqqoketh
 
PPTX
3分钟读懂加州大学伯克利分校毕业证UCB毕业证学历认证
bohjoj
 
PPTX
美国学位证书,奥本大学毕业证学历认证Auburn毕业证办
ewzt6ecilqqoketh
 
3分钟读懂密西根大学毕业证U-M毕业证学历认证
keaceh
 
3分钟读懂美国东北大学毕业证NEU毕业证学历认证
riecoa
 
英国学位证书,UIUC毕业证香槟分校毕业证学历认证UIUC毕业证办
gjgrege
 
一比一制作女王大学毕业证QU毕业证学校版本
betrui
 
3分钟读懂坎特伯雷大学毕业证UC毕业证学历认证
bohjoj
 
3分钟读懂德比大学毕业证Derby毕业证学历认证
juftee
 
3分钟读懂北卡罗莱纳大学毕业证UNC毕业证学历认证
hantil
 
3分钟读懂利兹三一大学毕业证LeedsTrinity毕业证学历认证
zughog
 
英国学位证书,考文垂大学毕业证学历认证Coventry毕业证制做
3of9
 
英国学位证书,爱丁堡大学毕业证学历认证Edin毕业证加急办理
3of9
 
3分钟读懂莱斯特大学毕业证Leicester毕业证学历认证
zughog
 
英国学位证书,拉夫堡大学毕业证学历认证LU毕业证买
3of9
 
3分钟读懂德蒙福特大学毕业证DMU毕业证学历认证
juftee
 
一比一制作威尔士大学毕业证UWIC毕业证学校版本
nihwuk
 
3分钟读懂创意艺术大学毕业证UCA毕业证学历认证
juftee
 
一比一制作斯旺西大学毕业证Swansea毕业证学校版本
nihwuk
 
3分钟读懂普渡大学毕业证Purdue毕业证学历认证
dukfis
 
美国学位证书,密歇根理工大学毕业证学历认证MTU毕业证加急购买
ewzt6ecilqqoketh
 
3分钟读懂加州大学伯克利分校毕业证UCB毕业证学历认证
bohjoj
 
美国学位证书,奥本大学毕业证学历认证Auburn毕业证办
ewzt6ecilqqoketh
 

教青少年寫程式