Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Python 程式設計入門 (二)
Search
EAGOAR 國際教育
November 11, 2016
Education
0
120
Python 程式設計入門 (二)
認識算術、關係、邏輯運算式及 input()、if/elif/else 指令。
EAGOAR 國際教育
November 11, 2016
Tweet
Share
More Decks by EAGOAR 國際教育
See All by EAGOAR 國際教育
EAGOAR 國際教育簡介
eagoar
0
120
Python 程式設計入門 (三)
eagoar
0
170
Python 程式設計入門 (一)
eagoar
0
320
Other Decks in Education
See All in Education
【dip】「なりたい自分」に近づくための、「自分と向き合う」小さな振り返り
dip_tech
PRO
0
180
Requirements Analysis and Prototyping - Lecture 3 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.3k
Web 2.0 Patterns and Technologies - Lecture 8 - Web Technologies (1019888BNR)
signer
PRO
0
3k
HCI and Interaction Design - Lecture 2 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.4k
JavaScript - Lecture 6 - Web Technologies (1019888BNR)
signer
PRO
0
3.1k
3Dプリンタでロボット作るよ#5_ロボット向け3Dプリンタ材料
shiba_8ro
0
120
The World That Saved Me: A Story of Community and Gratitude
_hashimo2
3
310
MySmartSTEAM 2526
cbtlibrary
0
100
今の私を形作る4つの要素と偶然の出会い(セレンディピティ)
mamohacy
2
120
Introdución ás redes
irocho
0
500
QR-koodit opetuksessa
matleenalaakso
0
1.7k
CSS3 and Responsive Web Design - Lecture 5 - Web Technologies (1019888BNR)
signer
PRO
1
3k
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
6.7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Raft: Consensus for Rubyists
vanstee
141
7.2k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Thoughts on Productivity
jonyablonski
73
5k
How GitHub (no longer) Works
holman
316
140k
The Invisible Side of Design
smashingmag
302
51k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Transcript
程式設計入門 (二)
Python 算術運算式
上堂課我們練習了加、減、乘、除運算,其中 +, - , * , / 我們稱之為運算符號。 這一堂,我們來介紹其他幾個運算符號: 1.
整除:// (範例畫面為 Mac電腦 Python Shell 畫面) 這個範例,可以很明顯看出 / 和 // 的不同。
2. 次方:** 3. 取餘數:%
4. 指定值到變數:= 程式設計有一個很重要的觀念叫「變數」,變數就像 一個容器,可以存放不同的值。看下面範例可以更容易 理解: a 和 b 就是所謂的變數。我們把計算後的值放入這兩個 變數中,分別輸入這兩個變數a和b後按「ENTER」,就
會顯示這兩個變數的數值。
Python 關係運算式
什麼是關係運算式?簡單說,就是比大小。這在往後程 式控制流程中將會是很重要的判斷。 運算符號 功用 運算符號 功用 < 小於 <= 小於或等於
== 等於 != 不等於 > 大於 >= 大於或等於 透過關係運算式判斷對 (True) 或錯 (False)。
Python 邏輯運算式
邏輯運算式就是「而且」、「或」、「非」: 運算符號 功用 運算符號 功用 and 而且 or 或 not
否、非 邏輯運算式的使用我們稍後再做說明。
Python IDLE 介面
為了開發越來越複雜的 程式,我們來介紹 Python 的 IDLE 開發介 面,讓我們可以把程式 碼存成一個檔案之後再 來執行。
請執行 Python 安裝完 後的 IDLE 程式。
IDLE 開啟後,執行 File/New File 開啟一個新檔案。
我們寫了一個新程式如下:
input( ) 指令會讀取鍵盤輸入的資料,一般會把資 料存在一個變數中。 指令:input( ) 判斷式,如果符合,就會執行該判斷式後面的動作。 特別提醒:If…elif...else 後面必須加:。
指令:if … elif ... else
這個程式就是讓使用者透過 input() 指令回答兩個問題, 然後依據回答,顯示不同的判斷結果。 在這個例子中,就可以看到邏輯運算式的應用。
之後另存新檔,附檔名只能是 py 或是 pyw。
Run/Run Module 執行程式。
程式執行結果:
1. 熟悉算數、關係、邏輯運算式。 2. 熟悉 input()、if/elif/else 用法。 本堂作業