Chloe
    • 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
    # 第1類:基本程式設計 ###### tags: `Python` `TQC` ## <span style="border: orange solid 2px;padding:4px 6px">101 整數格式化輸出</span>:star: ### 設計說明 請撰寫一程式,輸入四個整數,然後將這四個整數以欄寬為5、欄與欄間隔一個空白字元,再以每列印兩個的方式,先列印向右靠齊,再列印向左靠齊,左右皆以直線 |(Vertical bar)作為邊界。 ### 輸入說明 四個整數 ### 輸出說明 格式化輸出 ### 範例 ![](https://i.imgur.com/ztFOztx.png) ### 解答 ```python= num1 = eval(input()) num2 = eval(input()) num3 = eval(input()) num4 = eval(input()) print('|{:>5d} {:>5d}|'.format(num1,num2)) print('|{:>5d} {:>5d}|'.format(num3,num4)) print('|{:<5d} {:<5d}|'.format(num1,num2)) print('|{:<5d} {:<5d}|'.format(num3,num4)) ``` --- ## <span style="border: orange solid 2px;padding:4px 6px">102 浮點數格式化輸出</span> ### 設計說明 請撰寫一程式,輸入四個分別含有小數1到4位的浮點數,然後將這四個浮點數以欄寬為7、欄與欄間隔一個空白字元、每列印兩個的方式,先列印向右靠齊,再列印向左靠齊,左右皆以直線 |(Vertical bar)作為邊界。 >提示:輸出浮點數到小數點後第二位。 ### 輸入說明 四個浮點數 ### 輸出說明 格式化輸出 ### 範例 ![](https://i.imgur.com/ETrlcZP.png) ### 解答 ```python= num1 = eval(input()) num2 = eval(input()) num3 = eval(input()) num4 = eval(input()) print('|{:>7.2f} {:>7.2f}|'.format(num1,num2)) print('|{:>7.2f} {:>7.2f}|'.format(num3,num4)) print('|{:<7.2f} {:<7.2f}|'.format(num1,num2)) print('|{:<7.2f} {:<7.2f}|'.format(num3,num4)) ``` --- ## <span style="border: orange solid 2px;padding:4px 6px">103 字串格式化輸出</span> ### 設計說明 請撰寫一程式,輸入四個單字,然後將這四個單字以欄寬為10、欄與欄間隔一個空白字元、每列印兩個的方式,先列印向右靠齊,再列印向左靠齊,左右皆以直線 |(Vertical bar)作為邊界。 ### 輸入說明 四個單字 ### 輸出說明 格式化輸出 ### 範例 ![](https://i.imgur.com/7gZUrKG.png) ### 解答 ```python= str1 = str(input()) str2 = str(input()) str3 = str(input()) str4 = str(input()) print('|{:>10s} {:>10s}|'.format(str1,str2)) print('|{:>10s} {:>10s}|'.format(str3,str4)) print('|{:<10s} {:<10s}|'.format(str1,str2)) print('|{:<10s} {:<10s}|'.format(str3,str4)) ``` --- ## <span style="border: orange solid 2px;padding:4px 6px">104 圓形面積計算</span> ### 設計說明 請撰寫一程式,輸入一圓的半徑,並加以計算此圓之面積和周長,最後請印出此圓的半徑(Radius)、周長(Perimeter)和面積(Area)。 > 提示1:需import math模組,並使用math.pi。 > 提示2:輸出浮點數到小數點後第二位。 ### 輸入說明 半徑 ### 輸出說明 半徑 周長 面積 ### 範例 ![](https://i.imgur.com/0JansOU.png) ### 解答 ```python= import math radius = eval(input()) print("Radius = {:.2f}".format(radius)) print("Perimeter = {:.2f}".format(radius*2*math.pi)) print("Area = {:.2f}".format(radius**2*math.pi)) ``` --- ## <span style="border: orange solid 2px;padding:4px 6px">105 矩形面積計算</span> ### 設計說明 請撰寫一程式,輸入兩個正數,代表一矩形之寬和高,計算並輸出此矩形之高(Height)、寬(Width)、周長(Perimeter)及面積(Area)。 > 提示:輸出浮點數到小數點後第二位。 ### 輸入說明 高、寬 ### 輸出說明 高 寬 周長 面積 ### 範例 ![](https://i.imgur.com/nC9wQXt.png) ### 解答 ```python= h = eval(input()) w = eval(input()) print("Height = {:.2f}".format(h)) print("Width = {:.2f}".format(w)) print("Perimeter = {:.2f}".format(2*h+2*w)) print("Area = {:.2f}".format(h*w)) ``` --- ## <span style="border: orange solid 2px;padding:4px 6px">106 公里英哩換算</span> ### 設計說明 假設一賽跑選手在x分y秒的時間跑完z公里,請撰寫一程式,輸入x、y、z數值,最後顯示此選手每小時的平均英哩速度(1英哩等於1.6公里)。 > 提示:輸出浮點數到小數點後第一位。 ### 輸入說明 x(min)、y(sec)、z(km)數值 ### 輸出說明 速度 ### 範例 ![](https://i.imgur.com/OlqmTDw.png) ### 解答 ```python= x = eval(input()) y = eval(input()) z = eval(input()) print("Speed = {:.1f}".format((z/1.6)/((x/60)+(y/3600)))) ``` --- ## <span style="border: orange solid 2px;padding:4px 6px">107 數值計算</span> ### 設計說明 請撰寫一程式,讓使用者輸入五個數字,計算並輸出這五個數字之數值、總和及平均數。 > 提示:總和與平均數皆輸出到小數點後第1位。 ### 輸入說明 五個數字 ### 輸出說明 輸出五個數字 總和 平均數 ### 範例 ![](https://i.imgur.com/AjuVKCB.png) ### 解答 ```python= num1 = eval(input()) num2 = eval(input()) num3 = eval(input()) num4 = eval(input()) num5 = eval(input()) print(num1, num2, num3, num4, num5) total = num1+num2+num3+num4+num5 print("Sum = {:.1f}".format(total)) print("Average = {:.1f}".format(total/5)) ``` --- ## <span style="border: orange solid 2px;padding:4px 6px">108 座標距離計算</span>:star: ### 設計說明 請撰寫一程式,讓使用者輸入四個數字x1、y1、x2、y2,分別代表兩個點的座標(x1, y1)、(x2, y2)。計算並輸出這兩點的座標與其歐式距離。 > 提示1:歐式距離 ![](https://i.imgur.com/TicOoIP.png) > 提示2:兩座標的歐式距離,輸出到小數點後第4位 ### 輸入說明 四個數字x1、y1、x2、y2 ### 輸出說明 座標1 座標2 兩座標的歐式距離 ### 範例 ![](https://i.imgur.com/gV4W4QE.png) ### 解答 ```python= x1 = eval(input()) y1 = eval(input()) x2 = eval(input()) y2 = eval(input()) distance = ((x1-x2)**2 + (y1-y2)**2)**(0.5) print("(",x1,",",y1,")") print("(",x2,",",y2,")") print("Distance =",'{:.4f}'.format(distance)) ``` --- ## <span style="border: orange solid 2px;padding:4px 6px">109 正五邊形面積計算</span> ### 設計說明 請撰寫一程式,讓使用者輸入一個正數s,代表正五邊形之邊長,計算並輸出此正五邊形之面積(Area)。 >提示1:建議使用import math模組的math.pow及math.tan >提示2:正五邊形面積的公式:![](https://i.imgur.com/fb3Iviy.png) >提示3:輸出浮點數到小數點後第四位。 ### 輸入說明 正數s ### 輸出說明 正五邊形面積 ### 範例 ![](https://i.imgur.com/7ITbi2U.png) ### 解答 ```python= import math s = eval(input()) area = (5*math.pow(s,2))/(4*math.tan(math.pi/5)) print("Area = {:.4f}".format(area)) ``` --- ## <span style="border: orange solid 2px;padding:4px 6px">110 正n邊形面積計算</span> ### 設計說明 請撰寫一程式,讓使用者輸入兩個正數n、s,代表正n邊形之邊長為s,計算並輸出此正n邊形之面積(Area)。 >提示1:建議使用import math模組的math.pow及math.tan >提示2:正n邊形面積的公式如下:![](https://i.imgur.com/I4lDyKM.png) >提示3:輸出浮點數到小數點後第四位 ### 輸入說明 正數n、s ### 輸出說明 正n邊形面積 ### 範例 ![](https://i.imgur.com/fbn4fTX.png) ### 解答 ```python= import math n = eval(input()) s = eval(input()) area = (n*math.pow(s,2))/(4*math.tan(math.pi/n)) print("Area = {:.4f}".format(area)) ```

    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