Python Tutorial
Billy Su (@Billy4195)
About me
Billy Su(蘇炳立) –- GitHub:Billy4195
- 交大資工大四
- 自由軟體愛好者
- 吃飯工具
- 2016 7~8月 普安科技實習
- 2017 7~8月 聯發科技實習
投影片參考wdv4758h/Python-Introduction的內容
內容主要包含基本常用的東西,但不包含所有操作。
Outline
Introduction to Python
Guess number game(猜數字遊戲 4A0B)
Introduction
What is Python?
History
Python 是一個由 Guido van Rossum 在 1991 年 2 月釋出的程式語言, 發展至今大約過了 20 餘年, 廣泛使用於科學計算、網頁後端開發、系統工具等地方
Python 是源自於當時 Guido van Rossum 觀賞的 BBC 喜劇 「Monty Python's Flying Circus」
Features
Python2 & Python3
Python3在2008年12月3日首次釋出,與Python2不相容。
Python2 將在2020年後停止維護
所以~學新的比較潮(?)
Installation
Ubuntu
$ sudo apt-get install python3
Centos
Windows
零基礎學網頁爬蟲 01_安裝Python環境
Mac OSX
$ brew install python3
Start
Variable
A space for storing data
Example
Data types
- int
- float
- str
- list
- dict
- …
How to know the data type?
type()
list() element access
Arithemathic Operation
Integer(整數運算)
Floating Point(浮點數、小數運算)
Power (指數運算)
String(字串)
List(列表)
Relational Operation
Logical Operation
Output
If-else
Statement
for
Loop Statement
while
Loop Statment
Function
Module
Hello.py
main.py
Install module
pip3 install <Module name>
Using Standard Library
寫遊戲囉!
猜數字~
出題目
從 0-9選出四個隨機排列的數字
用 random module
主要結構
怎麼確認答案對不對
把string換成integer
怎麼確認答案正不正確
確認答案的每一個數字有沒有在猜測的數字裡
再確認位置是不是正確的
只能猜一次XD
用while loop解決
More about Python
- 網頁爬蟲
- Python3文件(找工具好去處)
- Stack Overflow(Copy & Paste寫程式?)
- Reddit Python(外國PTT)