江以薰
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 個人筆記 # 第一堂02/14 1.單純數學符號計算 | 符號 | 名稱 | 範例 | | -------- | -------------|---------| | + |加 |x + y | | - |減 |x - y | | * |乘 |x * y | | / |除 |x / y | | % |餘數 |x % y | | ** |次方 |x ** y(3**3=27)| | // |商 |x // y | 2.特殊數學符號計算 | 符號 | 範例 | 算法 | | -------- | ------- | ------- | | = |x = 5 |x = 5 | | += |x += 8 |x = x +8 | | -= |x -= 7 |x = x -7 | | *= |x *= 7 |x = x * 7| | /= |x /= 7 |x = x /7 | | %= |x %= 7 |x = x % 7| | **= | x //= 7 |x = x //7| | //= | x **= 7 |x = x **7| # 第二堂02/21 1.import math 匯入數學模組 ``` math.floor() 將括號裡的數無條件捨去 math.ceil() 將括號裡的數無條件進位 math.sqrt() 將括號裡的數開根號 ``` 2.單字定義 ``` max求最大值 min求最小值 abs絕對值 pow次方 Ex.pow(2,3)=8 ``` # 第三堂03/07 1."xx"引起來的為字串 2.函數、型態定義 ``` type() 查找括號內的資料型態 len() 算出括號內的長度(有幾項) sum() 算出括號裡所有值的總和 數值型態:int(整數),float(浮點數) 字串型態:str(字串) 容器型態:list, dict 布林型態:bool(布林值:可設定為兩種值True或False) ``` 3.例題解釋 (1) :::success ``` x="5" y="3" print(type(x)) #印出x的資料型態 print(type(y)) #印出y的資料型態 x+y #注意:如果x,y的資料型態不一樣,則兩者無法相加 ``` ``` <class 'str'> <class 'str'> 53 ``` ::: (2) :::success ``` a=input("Enter a age") b=input("Enter b age") print(a+b) #印出兩字串相加結果 a=int(a) #將字串a結果轉換為數值a b=int(b) #將字串b結果轉換為數值b print(a+b) #印出兩數值相加結果 ``` ``` Enter a age10 #會先出現Enter a age讓你填入數字 Enter b age10 #再出現Enter b age讓你填入數字 1010 20 ``` ::: (3) :::success ``` thislist = list(("apple", "banana", "cherry")) print(thislist[0]) #印出第一項 ``` ``` apple ``` 注意:0為第一項,1為第二項,-1為最後一項,-2為倒數第二項,以此類推 ::: (4) :::success ``` thislist=[9,80,32,78,69,83,92,35,21] thislist.sort() #將串列由小排到大 print(thislist) ``` ``` [9, 21, 32, 35, 69, 78, 80, 83, 92] ``` ::: (5)**迴圈** :::success ``` thislist = ["apple", "banana", "cherry"] for x in thislist: print(x) ``` ``` apple banana cherry ``` ::: # 第四堂03/14 1.例題解釋 (1) :::success ``` lst=['a','b','c','d','e'] print(lst[1:3]) #切片的意思,1為ab之間 ``` ``` ['b', 'c'] ``` ::: (2) :::success ``` lst=['a','b','c','d','e'] lst[2]='x' print(lst) #將編號2(第三項)改成x ``` ``` ['a', 'b', 'x', 'd', 'e'] ``` ::: (3) :::success ``` lst=['a','b','c','d','e']#宣告一個變數lst代表一個串列有五個元素分別為a字串,b字串,c字串,d字串,e字串 lst[2]='x'#lst串列裡編號為二的元素設定為x lst.append('c')#在lst串列裡附加一個元素c lst.append('c') lst.remove('b')#在lst串列裡移除一個元素b print(lst) lst.sort()#使用排序功能 print(lst) print(lst.count('c'))#印出字串c在串列裡出現幾次 ``` ``` ['a', 'x', 'd', 'e', 'c', 'c'] ['a', 'c', 'c', 'd', 'e', 'x'] 2 ``` ::: (4) :::success ``` lst=[9,80,32,78,69,83,92,35,21] for x in lst: if x>0 and x<50: print('第一組') print(x) if x>50 and x<100: print('第二組') print(x) ``` ``` 第一組 9 第二組 80 第一組 32 第二組 78 第二組 69 第二組 83 第二組 92 第一組 35 第一組 21 ``` ::: # 第五堂03/21 1.例題解釋 (1)求總和、最大值 :::success ``` lst=[9,80,32,78,69,83,92,35,21] a=0 #宣告一個總和變數a,設定為0 for x in lst: a=x+a print(a) b=0 #設定一個變數b,放置最大值 for x in lst: if x>b: b=x print(b) ``` ``` 499 92 ``` ::: (2) :::success ``` a=[3,5,7,4,6] y=0 z=0 for x in a: y=y+x if x>z : z=x print(x) print(y) print(z) ``` ![](https://i.imgur.com/7mw7YFe.png) ``` 6 25 7 ``` ::: # 第六堂03/28 1.例題解釋 (1)繪圖 :::success ``` #使用畫圖套件 matplotlib.pyplot import matplotlib.pyplot as plt a=[1,2,3,4,5] b=[1,2,3,4,5] plt.scatter(x=a,y=b,s=10) #括弧裡為參數,整個為函數 plt.axis('square') #軸為正方形 plt.xlim(0,6) #x軸範圍設定在0-10之間 plt.ylim(0,6) print(f'我的圖形') plt.show() ``` 答案省略 ::: (2) :::success ``` dic={'WaterMelon':100, 'Apple':40} #watermelon為鍵,100為值 print( dic['WaterMelon'] ) ``` ``` 100 ``` ::: :::success ``` thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } thisdict["color"] = "red" #加入一個配對,鍵為color,值為red print(thisdict) ``` ``` {'brand': 'Ford', 'model': 'Mustang', 'year': 1964, 'color': 'red'} ``` ::: (3) :::success dict={'WaterMelon':'100', 'Apple':'40', 'Banana':'30', 'Orange':'20', 'peach':'50', 'Grape':'25'} ``` for x in dict: print(x) ``` ``` WaterMelon Apple Banana Orange peach Grape ``` ``` for x in dict.values(): print(x) ``` ``` 100 40 30 20 50 25 ``` ``` for x, y in dict.items(): print(x, y) ``` ``` WaterMelon 100 Apple 40 Banana 30 Orange 20 peach 50 Grape 25 ``` ``` a=set() for x in dict.values(): a.add(x[0:1]) print(a) ``` ``` {'4', '3', '1', '5', '2'} ``` ``` lst = (dict.values()) emptylist = [] emptydict = {} for i in lst: emptylist.append(i[:1]) for i in emptylist: emptydict[i] = emptydict.get(i,0) + 1 Value = emptydict.values() Key = emptydict.keys() TValue = tuple(Value) TKey = tuple(Key) for i in range(len(TValue)): print(f'{TKey[i]}出現了{TValue[i]}次') ``` ``` 1出現了1次 4出現了1次 3出現了1次 2出現了2次 5出現了1次 ``` ::: # 第七堂04/11 1.例題解釋 (1)寫入CSV :::success ``` # 手工掛載雲端硬碟 with open('/content/drive/MyDrive/___DataSet/001_Hello.txt', 'w') as f: f.write('Hello Google Drive') ``` #with:以...為基礎 ::: (2)讀取CSV :::success ``` with open('/content/drive/MyDrive/___DataSet/001_Hello.txt', 'r') as f: ss=f.read() print(ss) ``` ``` Hello Google Drive ``` ::: (3)刪除檔案 :::success ``` import os if os.path.exists("/content/drive/MyDrive/___DataSet//001_Hello.txt"): os.remove("/content/drive/MyDrive/___DataSet//001_Hello.txt") print("檔案已經刪除") else: print("檔案不存在")# 刪除檔案 ``` ``` 檔案已經刪除 ``` ::: (4)讀取雲端硬碟中的excel檔 :::success ``` import pandas as pd df = pd.read_excel('/content/drive/My Drive/___DataSet/001_Income_F.xlsx') df ``` ::: (5) :::success ``` import pandas as pd grades = { "name": ["Mike", "Sherry", "Cindy", "John"], "math": [80, 75, 93, 86], "chinese": [63, 90, 85, 70] } df = pd.DataFrame(grades) df ``` ``` name math chinese 0 Mike 80 63 1 Sherry 75 90 2 Cindy 93 85 3 John 86 70 ``` ::: (6) :::success ``` grades = [ ["Mike", 80, 63], ["Sherry", 75, 90], ["Cindy", 93, 85], ["John", 86, 70] ] df = pd.DataFrame(grades) df.columns = ["student_name", "math_score", "chinese_score"] #自訂欄位名稱 df.columns = ["name", "math", "chinese"] #修改欄位名稱 df ``` ``` name math chinese 0 Mike 80 63 1 Sherry 75 90 2 Cindy 93 85 3 John 86 70 ``` ::: (7) :::success ``` grades = [ ["Mike", 80, 63], ["Sherry", 75, 90], ["Cindy", 93, 85], ["John", 86, 70] ] print(df.head(2)) #取得最前面的兩筆資料" print(df.tail(3)) #取得最後面的三筆資料" ``` ``` 學號 體重 身高 0 A001 60 165 1 A002 50 157 學號 體重 身高 2 A003 80 182 3 A004 75 175 4 A005 72 170 ``` ::: (8) :::success ``` print("取得索引值0~2的資料") print(df[0:3]) ``` ``` 取得索引值0~2的資料 學號 體重 身高 0 A001 60 165 1 A002 50 157 2 A003 80 182 ``` ::: (9) :::success df.at[1, "身高"] ``` 157 ``` df.iat[4,2] ``` 170 ``` df.loc[[1, 3], ["學號", "體重"]] ``` 學號 體重 1 A002 50 3 A004 75 ``` df.iloc[[1, 3], [0, 2]] ``` 學號 身高 1 A002 157 3 A004 175 ``` ::: (10) :::success ``` list(range(1,10)) ``` ``` [1, 2, 3, 4, 5, 6, 7, 8, 9] ``` ::: (11) :::success ``` for i in range(0,5): print(i) print(df.at[i,"學號"]) ``` ``` 0 A001 1 A002 2 A003 3 A004 4 A005 ``` ::: (12) :::success ``` for i in range(0,5): for j in range(0,5): print(f'{i},{j}') ``` ``` 0,0 0,1 0,2 0,3 0,4 1,0 1,1 1,2 1,3 1,4 2,0 2,1 2,2 2,3 2,4 3,0 3,1 3,2 3,3 3,4 4,0 4,1 4,2 4,3 4,4 ``` ::: (13) :::success ``` import pandas as pd grades = { "學號": ["A001","A002","A003","A004","A005"], "體重": [60,50,80,75,72], "身高": [165,157,182,175,170] } df = pd.DataFrame(grades) for i in range(0,5): print(df.at[i, "學號"]) for j in range(0,1): print(df.at[i, "體重"]) for x in range(0,1): print(df.at[i, "身高"]) ``` ``` A001 60 165 A002 50 157 A003 80 182 A004 75 175 A005 72 170 ``` ::: 2.容器型態 (1)串列 (2)字典 (3)集合 (4)data frame # 第八堂04/25 1.老師上課講解加分作業 2.討論個人加分作業 3.討論小組期末作業報告 # 第九堂05/02 1.老師講解作業程式 2.討論小組期末作業報告 # 第十堂05/09 1.excel輸入&跑圖 (1)![](https://i.imgur.com/6euNg3n.png) (2)![](https://i.imgur.com/7YgyQPx.png) 2.colab https://colab.research.google.com/drive/1zpNy8QsILBC6iCR6YlH2h_vOovFf6Y-W # 第十一堂05/16 1.上課內容 (1) :::success ``` #計算1,2,.....,n的總和 n=10 s=0 for i in range(1,n+1): s=s+i print(s) ``` ``` 55 ``` ::: (2) :::success ``` def Sum1toN(n): s=0 n=10 for i in range(1,n+1): s=s+i return s Sum1toN(n) ``` ``` 55 ``` ::: (3) :::success ``` def my_function(): print("Hello from a function") my_function() ``` ``` Hello from a function ``` ::: (4) :::success ``` def myfun(x,y,z): print(x+"你好"+y+z) myfun("同學","啊","早安") ``` ``` 同學你好啊早安 ``` ::: (5) :::success ``` def mycal(x,y,z): print(x+y+z) mycal(3,5,2) mycal(y=5,x=3,z=2) ``` ``` 10 10 ``` ::: (6) :::success ``` def mycal(x,y): z=x+y return z a=mycal(10,5) print(a) def mycal(x,y): z=x+y return z b=mycal(x=10,y=5) print(b) ``` ``` 15 15 ``` ::: (7) :::success ``` def mycal(x,y,z): i=x+y+z return i a=mycal(3,5,2) print(a) ``` ``` 10 ``` ::: 2.小考內容 (1)請定義一個函數myFunction,傳入一個參數n。此函數可以計算出1,2,…,n的總和。函數能傳回後的總和。(必須用for迴圈完成) :::success ``` def myFunction(n): #設定一個函數myFunction,傳入一個參數n s=0 #令一個變數s=0 for i in range(1,n+1): #針對range內的元素設定為i s=s+i #把s+i的值再設定回s return s #回傳s myFunction(10) #n代10得出解答 ``` ``` 55 ``` ::: (2)請定義一個函數myFunction,傳入一個參數n。此函數可以找出1,2,…,n的之間2的倍數,並列印出到螢幕上。(必須用for迴圈完成) :::success ``` def myFunction(n): #設定一個函數myFunction,傳入一個參數n s=0 #令一個變數s=0 for i in range(1,n+1): #針對range內的元素設定為i if i%2==0: #如果i除以2的餘數等於0 print(i) #將i印出 myFunction(10) #把n代10函數印出 ``` ``` 2 4 6 8 10 ``` ::: (3)請在螢幕上印出如下圖案 (必須用for迴圈完成) :::success ``` s='*' #設定一個變數s為'*' for i in range(1,14): #針對range內的元素設定為i if i%2==1: #如果i除以2的餘數等於1 a=i*s #將i乘上變數指定給a print(a) #將a印出 ``` ``` * *** ***** ******* ********* *********** ************* ``` ::: # 第十二堂05/23 小考作答狀況+助教解題訂正 https://colab.research.google.com/drive/1AQc30_UHnxYTpq0uG2V5kzZLOVKe8s_2

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully