從頭學Python
講者:楊斯丞
時間:12/15
地點:LE5A
大綱
-
How to coding with python?
-
資料結構
-
流程控制
-
函數
How to coding with Python?
- command line
- Python IDLE
- Vscode
simple code
print("hello world")資料型態
- 數值型態:int, float, bool
- 字串型態:str, chr
- 容器型態:list, dict, tuple
try it yourself
A = "hello world"
print(type(A))
#我是註解
B = 123
print(type(B))
C = "123"
print(type(C))加減乘除
「+」「-」「*」「/」「%」「=」
try it yourself
二加三
五加二十
八十乘以一百九十五
七十五除以五等於餘多少
兩百除以十五等於多少餘多少
print(2+3)
print((5+20)*6)
print(80*195)
print(75%5)
print(200/15)
變數
try it yourself
List 串列
fruits = ["apple","apple","orange","pear","banana","kiwi","banana"]
print(fruits.count("apple"))
print(fruits.index("orange"))
print(fruits.index("banana",5))
print(fruits.reverse())
print(fruits)
print(fruits.sort())
print(fruits.pop())Tuple數組
-
可從字串取得
-
也可從tuple轉成list
try it yourself
tp1 = ()
print(tp1)
tp2= (1,2,3,4,5,6,7,8)
print(tp2)
print(sum(tp2))
print("===================")
print(tp2[2:5])
print(tp2[-1])
print("===================")
tp4 = tuple("FJU LINS")
print(tp4)
tp5=("Jhon","Mary","Nick")
print(len(tp5))
print(tp4+tp5)
print("===================")
tp6 = tuple([1,1,1,2,3,3,3,4,5,6,6,6,7,10,8])
print(tp6)
print(max(tp6))
print(min(tp6))控制結構
-
if
-
while for
IF
-
if
-
else
for
-
for
-
while
python
By Lamuyang
python
- 63