<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Python &#8211; 龍冥 Blog</title>
	<atom:link href="https://dragongo.co/category/codeteach/python/feed/" rel="self" type="application/rss+xml" />
	<link>https://dragongo.co</link>
	<description>Code &#38; Read</description>
	<lastBuildDate>Fri, 06 Mar 2026 13:34:06 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.9</generator>

<image>
	<url>https://dragongo.co/wp-content/uploads/2021/05/cropped-cropped-LOGO-2-e1655437907165-32x32.png</url>
	<title>Python &#8211; 龍冥 Blog</title>
	<link>https://dragongo.co</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【Python超入門教學】EP4 &#124; 判斷我說的話是不是真的? (if-elif-else)</title>
		<link>https://dragongo.co/python-beginner-if-elif-else-tutorial/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Fri, 06 Mar 2026 13:34:03 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[程式教學]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[教學]]></category>
		<category><![CDATA[註解]]></category>
		<category><![CDATA[註解的習慣]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=2634</guid>

					<description><![CDATA[本文說明程式註解在專案開發中的正確定位與使用原則，強調註解應用於說明複雜邏輯，而非取代除錯工具。作者分享從初學大量使用 print 與註解測試，到轉向專業開發流程的經驗，說明過度註解與臨時除錯碼會降低程式可維護性。文章建議透過 Git 管理測試歷程，並導入 Log 系統取代臨時輸出，同時介紹 Python 單行與多行註解的實務用法，協助開發者建立清晰、穩定且可長期維護的程式架構。]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="2634" class="elementor elementor-2634">
						<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-052f0ea elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="052f0ea" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f371213" data-id="f371213" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-92edea3 elementor-widget elementor-widget-text-editor" data-id="92edea3" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2>流程控制：條件判斷 (if / elif / else)</h2><p>透過程式讓電腦具有「思考」能力，能根據不同的情況執行不同的程式碼區塊。例如：當密碼正確時允許使用者登入；若密碼錯誤，則顯示錯誤訊息。</p><hr /><h2>給電腦的判斷句 (&gt;、&lt;、=)</h2><p>在撰寫 <code>if</code> 相關指令之前，必須先理解電腦如何判斷條件。</p><h3>「等於」不只是等於？搞懂 <code>=</code> 與 <code>==</code> 的差別</h3><p>在數學中，我們習慣使用 <code>=</code> 表示兩邊相等（雖然《鋼之鍊金術師》的等價交換也不是這樣寫的 <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f606.png" alt="😆" class="wp-smiley" style="height: 1em; max-height: 1em;" />）。但在程式碼中，這兩個符號的意義完全不同：</p><ul><li><p><strong>單個等於 <code>=</code>（指定 Assignment）：</strong></p><p>可以想像成「把右邊的東西放進左邊的盒子」。</p><pre><code class="language-python">x = 10
</code></pre><p>代表：把數字 <code>10</code> 放進變數 <code>x</code> 這個盒子裡。</p></li><li><p><strong>兩個等於 <code>==</code>（比較 Comparison）：</strong></p><p>這是在「提出一個問題」。</p><pre><code class="language-python">x == 10
</code></pre><p>代表：<code>x</code> 裡面的值是否等於 <code>10</code>？</p><p>這個寫法通常會出現在 <code>if</code> 的條件判斷中，讓電腦檢查條件是否成立。</p></li></ul><hr /><h2>布林值 (Boolean)：只有是與否的世界</h2><p>當電腦判斷 <code>if</code> 後面的條件時，只會得到兩種結果：</p><ul><li><code>True</code>（真 / 條件成立）</li><li><code>False</code>（假 / 條件不成立）</li></ul><p>這種只有兩種結果的邏輯，在程式中稱為 <strong>布林值（Boolean）</strong>。</p><h3>為什麼 Boolean 很重要？</h3><p>因為 <code>if</code> 的運作邏輯非常單純：</p><ul><li>如果條件結果是 <strong>True</strong> → 執行縮排區塊內的程式</li><li>如果條件結果是 <strong>False</strong> → 直接跳過該區塊</li></ul><pre><code class="language-python">5 &gt; 3 結果：<code>True</code> </code></pre><pre><code class="language-python">10 &lt; 2 結果：<code>False</code></code></pre><pre><code class="language-python">num % 2 == 0 意思是：數字除以 2 的餘數是否等於 0？</code></pre><ul><li>如果 <code>num = 4</code> → <code>True</code>（偶數）</li><li>如果 <code>num = 5</code> → <code>False</code>（奇數）</li></ul><hr /><h2>if 的基礎寫法</h2><p>Python 使用 <strong>縮排（indentation）</strong> 來定義程式區塊。這與 C / Java 常見的大括號 <code>{}</code> 不同，而且縮排是 <strong>語法強制要求</strong>。</p><p>在多數編輯器中，可以先選取程式碼後：</p><ul><li><code>Tab</code> → 增加縮排</li><li><code>Shift + Tab</code> → 減少縮排</li></ul><h3>if / elif / else 基本結構</h3><pre><code class="language-python">if 條件1:
    符合條件1時執行
elif 條件2:
    條件1不成立，但條件2成立時執行
elif 條件3:
    條件1與條件2都不成立，但條件3成立時執行
else:
    以上條件都不成立時執行
</code></pre><hr /><h3>範例：判斷數字是正數、負數或零</h3><pre><code class="language-python">x = float(input("輸入一個數字: "))

if x &gt; 0:
    print("這是正數")
elif x &lt; 0:
    print("這是負數")
else:
    print("這是零")
</code></pre><p>程式流程：</p><ol><li>使用者輸入一個數字</li><li>如果 <code>x &gt; 0</code> → 顯示「這是正數」</li><li>如果 <code>x &lt; 0</code> → 顯示「這是負數」</li><li>其他情況 → 顯示「這是零」</li></ol><hr /><h2>巢狀條件（Nested if）</h2><p>Python 允許在 <code>if</code> 區塊內再撰寫另一層 <code>if</code>，形成 <strong>巢狀條件（Nested if）</strong>，用來處理更細緻的判斷邏輯。</p><h3>範例邏輯</h3><ol><li>先判斷數字是否大於 0</li><li>如果大於 0，再判斷它是奇數還是偶數</li><li>如果小於或等於 0，則不進行奇偶數判斷</li></ol><pre><code class="language-python">num = int(input("請輸入整數: "))

if num &gt; 0:
    print("大於 0")

    # 第二層判斷（巢狀 if）
    if num % 2 == 0:
        print("且是偶數")
    else:
        print("且是奇數")

else:
    print("小於或等於 0")
</code></pre><p>透過巢狀條件，可以讓程式逐層篩選條件，處理更複雜的邏輯情境。</p><p><!-- notionvc: f4b1cbbf-1b4c-48bb-86a6-8e9406a03023 --></p>								</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>【Python超入門教學】EP3 &#124; 註解又不會動，幹嘛打?</title>
		<link>https://dragongo.co/python-comments-and-debugging-best-practices/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Mon, 02 Feb 2026 11:16:11 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[程式教學]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[教學]]></category>
		<category><![CDATA[註解]]></category>
		<category><![CDATA[註解的習慣]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=2621</guid>

					<description><![CDATA[本文說明程式註解在專案開發中的正確定位與使用原則，強調註解應用於說明複雜邏輯，而非取代除錯工具。作者分享從初學大量使用 print 與註解測試，到轉向專業開發流程的經驗，說明過度註解與臨時除錯碼會降低程式可維護性。文章建議透過 Git 管理測試歷程，並導入 Log 系統取代臨時輸出，同時介紹 Python 單行與多行註解的實務用法，協助開發者建立清晰、穩定且可長期維護的程式架構。]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="2621" class="elementor elementor-2621">
						<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-052f0ea elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="052f0ea" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f371213" data-id="f371213" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-92edea3 elementor-widget elementor-widget-text-editor" data-id="92edea3" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2>註解 (Comments)</h2>
<p>註解是程式碼中不會被電腦執行的部分，核心目的是用來解釋程式邏輯或暫時讓某段程式失效。</p>
<p>註解的目的不是要讓初學者看懂你在幹嘛，而是用來提醒專家和你自己困難邏輯的部分在幹嘛，如果這個功能邏輯較為複雜，或有特殊考量時，就必須要在附近加上註解，但如果是很基礎簡單的部分，就不要再加上註解，否則會增加撰寫程式的時間。詳細的註解規則可參考Python專業社群的<a href="https://peps.python.org/pep-0008/" target="_blank" rel="noopener">PEP8</a>規範。</p>
<h3>單行註解</h3>
<ul>
<li><strong>符號</strong>：使用 <code>#</code>。</li>
<li><strong>功能</strong>：電腦會忽略 <code>#</code> 之後的該行文字。</li>
<li><strong>快捷鍵</strong>：在 Colab 或 VS Code 中，選取程式碼後按 <code>Ctrl</code> + <code>/</code> 可快速切換註解。</li>
</ul>
<h3>多行註解（區塊註解）</h3>
<ul>
<li>
<p><strong>符號</strong>：使用三個雙引號 <code>"""</code> 或三個單引號 <code>'''</code> 將文字包覆起來。</p>
</li>
<li>
<p><strong>功能</strong>：允許文字跨越多行，常當作「區塊註解」使用，或用於暫時停用一大段程式碼。</p>
</li>
<li>
<p><strong>技術細節</strong>：在 Python 的定義中，這其實是「多行字串 (Multi-line String)」。但如果這個字串<strong>沒有賦值給任何變數</strong>（即沒有寫 <code>text = ...</code>），Python 執行時會讀取它但不會做任何處理，效果等同於註解。</p>
</li>
<li>
<p><strong>範例</strong>：</p>
<pre><code>"""
這是一個多行註解的範例
你可以寫很多行
電腦都會略過不執行
"""
print("Hello")
</code></pre>
</li>
</ul>
<h2>在開發專案時，不要把註解當成debug的工具</h2>
<p>早期學習程式時，常把除錯當成主要工具：在迴圈中大量 print 資訊，或用快捷鍵反覆註解、取消註解測試程式碼，一邊修改一邊拼出最終版本。當程式規模還在五百行內時，這種方式尚可運作。</p>
<p>但隨著專案複雜度提高，開發週期拉長，多個專案同步進行，中途又可能因瓶頸或突發任務而中斷。幾個月後回頭看程式碼時，混雜其中的大量測試片段與除錯 print ，反而成了干擾理解的雜訊，使維護更加困難。</p>
<p>當註解與臨時測試累積到一定程度，就必須轉向更正規的開發模式。註解應回歸「提示」本質，而非暫時性的測試工具。</p>
<p>針對測試程式碼，建議透過 Git 管理開發歷程。當功能穩定後，可放心清除測試內容，需要時再從舊版本取用即可。至於複雜邏輯的追蹤，則應導入 Log 模組，統一使用 log.debug() 輸出資訊。封裝成執行檔時，只需調高顯示層級，即可隱藏除錯訊息，同時保留錯誤紀錄。</p>
<p>透過這樣的做法，能有效降低註解與臨時輸出的干擾，讓專案維持清晰且可維護的狀態。</p>
<h2>歪樓的部分</h2>
<p>我之前在寫code壓力大時，曾在我所有的code原始碼中，加入大量的圖像註解，一來是抒發壓力，二來是留一個趣味的東西給後人看，是看到<a href="https://www.dcard.tw/f/talk/p/238310528" target="_blank" rel="noopener">Dcard工程師的code</a>得到的靈感<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f923.png" alt="🤣" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><!-- notionvc: 5989e345-138a-4db1-be30-be21b217090b --></p>								</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>【Python超入門教學】EP2 &#124; 資料型態：新手常見誤區</title>
		<link>https://dragongo.co/python-data-types-common-errors/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Sun, 25 Jan 2026 10:24:56 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[程式教學]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[四則運算]]></category>
		<category><![CDATA[常見錯誤]]></category>
		<category><![CDATA[資料型態]]></category>
		<category><![CDATA[超入門教學]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=2597</guid>

					<description><![CDATA[Python 資料型態超入門：掌握 int、float、str 與 Boolean 核心觀念。解析 input() 轉型陷阱與 type() 除錯技巧，並詳列變數命名保留字規範，協助初學者避開常見語法錯誤，建立正確程式邏輯。]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="2597" class="elementor elementor-2597">
						<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-052f0ea elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="052f0ea" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f371213" data-id="f371213" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-92edea3 elementor-widget elementor-widget-text-editor" data-id="92edea3" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>在程式語言中，電腦需要知道「現在處理的是什麼資料」，才能決定該做什麼動作。例如：數字可以相加 (<code>1+1=2</code>)，但文字相加是串接 (<code>"1"+"1"="11"</code>)。</p>
<h2>為什麼需要資料型態？</h2>
<p>Python 雖然不需要像 C 語言一樣在宣告變數時強制定義型態（例如 <code>int a</code>），但它在執行時仍有嚴格的型態區分。若型態不對，程式會出現非預期運作方式甚至無法執行。</p>
<h3>常見的基礎型態</h3>
<p>我整理一些對於入門新手的人來講，初學必須先知道的幾個資料型態，但電腦還有很多更進階的資料型態，也很常用到，如list、tuple等型態，但為了入門學習，在本篇文章就先不提。</p>
<ul>
<li><strong>整數 (int)</strong>：Integer。完整的數字，不帶小數點。
<ul>
<li>範例：<code>1</code>, <code>50</code>, <code>10</code>, <code>18</code></li>
</ul>
</li>
<li><strong>浮點數 (float)</strong>：Floating-point。帶有小數點的數字。
<ul>
<li>範例：<code>3.14</code>, <code>0.5</code>, <code>1.0</code> (即使是 .0 也是浮點數)</li>
</ul>
</li>
<li><strong>字串 (str)</strong>：String。文字資料，必須用引號包覆。
<ul>
<li>範例：<code>"龍龍"</code>, <code>"Hello"</code>, <code>"123"</code> (被引號包起來的數字也是字串)</li>
</ul>
</li>
<li><strong>布林值 (Boolean)：只有是和否的二種狀態，常用在判斷句 (if) 中，也可以是比較運算的結果。</strong>
<ul>
<li>範例：<code>10 &gt; 3   # True</code></li>
</ul>
</li>
<li><strong>空值 (None)：代表「沒有值」、「尚未設定」。用來表示「這裡現在沒有有效資料」</strong>
<ul>
<li>範例：<code>data = None</code></li>
</ul>
</li>
</ul>
<h2>檢查資料型態：<code>type()</code></h2>
<p>當我們不確定某個變數是什麼型態時，可以使用 <code>type()</code> 函數來檢查。這在除錯（Debug）時非常重要。例如1+1出來不是2，而是11時，就可透過 type() 函數來判斷變數 (var) 是否為字串 (str) 類型造成的錯誤。</p>
<p><!-- notionvc: 82d90d5e-6176-4d3b-b273-83131b06d5e4 --></p>								</div>
				</div>
				<div class="elementor-element elementor-element-9a5ba7b elementor-widget elementor-widget-code-block-for-elementor" data-id="9a5ba7b" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>n1 = 1
f1 = 3.14
s1 = &quot;文字&quot;

print(type(n1))  # 輸出：&lt;class &#039;int&#039;&gt;
print(type(f1))  # 輸出：&lt;class &#039;float&#039;&gt;
print(type(s1))  # 輸出：&lt;class &#039;str&#039;&gt;</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-f8ef658 elementor-widget elementor-widget-text-editor" data-id="f8ef658" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2>數值四則運算對資料型態的影響</h2>
<p>在 Python 中，不同的運算符號會產生不同結果的資料型態，特別是<strong>除法</strong>。</p>
<h3>四則運算的寫法</h3>
<p>在變數的四則運算中，會因應結果的不同，進而產生出不同的資料型態，在撰寫code時，要稍加注意，以避免後續設計產生非預期的結果，如不確定，可透過type() 來輔助判斷結果的資料型態。</p>
<p>請特別注意除法 (/) 與取商數 (//) 的差別，如果後續程式邏輯依賴「整數」，請務必使用 <code>//</code> 或用 <code>int()</code> 轉變成整數的資料型態。</p>
<ul>
<li><code>10 / 2</code> 結果是 <code>5.0</code> (float)</li>
<li><code>10 // 2</code> 結果是 <code>5</code> (int)</li>
</ul>								</div>
				</div>
				<div class="elementor-element elementor-element-1b62eab elementor-widget elementor-widget-code-block-for-elementor" data-id="1b62eab" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>a = 1
b = 50

print(a + b)   # 加法：51
print(a - b)   # 減法：-49
print(a * b)   # 乘法：50
print(a / b)   # 除法：0.02 (注意：Python 的除法結果永遠是 float)
print(a // b)  # 商數 (整除)：0 (無條件捨去小數部分)
print(a % b)   # 餘數：1
print(a ** b)  # 次方：1 的 50 次方
</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-3850731 elementor-widget elementor-widget-text-editor" data-id="3850731" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2><code>input()</code> 的型態陷阱與轉型 (Type Casting)</h2>
<p>intput() 回傳的資料型態是「<strong>字串 (str)</strong>」，這是初學者很容易踩到的「新手陷阱」。</p>
<h3>陷阱：input 永遠是字串</h3>
<p>無論使用者輸入的是文字還是數字，<code>input()</code> 函數接收進來的資料，電腦<strong>一律視為字串 (str)</strong>。</p>
<p><!-- notionvc: f26de534-e08b-4c0a-aea1-9bdf1e6c728a --></p>								</div>
				</div>
				<div class="elementor-element elementor-element-63a6be5 elementor-widget elementor-widget-code-block-for-elementor" data-id="63a6be5" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 錯誤示範
user_in = input(&quot;請輸入數字：&quot;)  # 假設使用者輸入 5
# print(user_in + 1)           # 報錯！TypeError
# 原因：字串 &quot;5&quot; 不能直接跟數字 1 相加
</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-7b0ce6a elementor-widget-divider--view-line elementor-widget elementor-widget-divider" data-id="7b0ce6a" data-element_type="widget" data-e-type="widget" data-widget_type="divider.default">
				<div class="elementor-widget-container">
							<div class="elementor-divider">
			<span class="elementor-divider-separator">
						</span>
		</div>
						</div>
				</div>
				<div class="elementor-element elementor-element-9ec22b5 elementor-widget elementor-widget-text-editor" data-id="9ec22b5" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h3>解法：資料型態轉換</h3>
<p>下面範例中提到 user_in 的型態是 &lt;class &#8216;str&#8217;&gt;，而 user_int 的型態是 &lt;class &#8216;int&#8217;&gt;。務必記得 input 讀進來的變數若要進行運算，必須先透過 int() 或 float()進行資料型態的轉換。</p>
<ul>
<li><strong><code>int()</code></strong>：轉為整數。</li>
<li><strong><code>float()</code></strong>：轉為浮點數。</li>
<li><strong><code>str()</code></strong>：轉為字串。</li>
</ul>								</div>
				</div>
				<div class="elementor-element elementor-element-306465c elementor-widget elementor-widget-code-block-for-elementor" data-id="306465c" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 正確寫法
user_in = input(&quot;請輸入數字：&quot;)       # 讀取輸入 (str)
user_int = int(user_in)             # 轉型為整數 (int)

print(f&quot;輸入數字+1 = {user_int + 1}&quot;) # 現在可以運算了

# 也可以寫成一行：
# age = int(input(&quot;請輸入年齡：&quot;))</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-44e571c elementor-widget-divider--view-line elementor-widget elementor-widget-divider" data-id="44e571c" data-element_type="widget" data-e-type="widget" data-widget_type="divider.default">
				<div class="elementor-widget-container">
							<div class="elementor-divider">
			<span class="elementor-divider-separator">
						</span>
		</div>
						</div>
				</div>
				<div class="elementor-element elementor-element-0c3cc61 elementor-widget elementor-widget-text-editor" data-id="0c3cc61" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2>變數命名規則：保留字 (Reserved Words)</h2><p>在命名變數時，不能使用 Python 已經賦予特殊功能的單字（保留字），否則會發生語法錯誤 (<code>SyntaxError: invalid syntax</code>) 或導致程式功能異常。</p><h3>絕對不能用的字 (Keyword)</h3><p>這些字在 Python 語法中有特定用途，不能當變數名：</p><ul><li><code>if</code>, <code>else</code>, <code>for</code>, <code>while</code>, <code>class</code>, <code>def</code>, <code>return</code>, <code>import</code>, <code>True</code>, <code>False</code>, <code>None</code> 等。</li></ul><h3>建議不要用的字 (Built-in Functions)</h3><p>這些是 Python 內建的函數名，雖然語法上允許覆蓋，但會導致原本功能失效（極度危險）：</p><ul><li><code>print</code>, <code>input</code>, <code>int</code>, <code>str</code>, <code>list</code>, <code>type</code></li></ul>								</div>
				</div>
				<div class="elementor-element elementor-element-b666788 elementor-widget elementor-widget-code-block-for-elementor" data-id="b666788" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 危險示範
# print = 100
# print(&quot;Hello&quot;)  # 會報錯，因為 print 已經變成數字 100，不再是函數了</code></pre>				</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>【Python超入門教學】EP1 &#124; 輸出到輸入</title>
		<link>https://dragongo.co/python-basics-input-output/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Mon, 19 Jan 2026 11:42:28 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[程式教學]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[variable]]></category>
		<category><![CDATA[超入門教學]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=2569</guid>

					<description><![CDATA[輸出指令：print() 的核心與細節 prin&#8230;]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="2569" class="elementor elementor-2569">
						<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-052f0ea elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="052f0ea" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f371213" data-id="f371213" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-92edea3 elementor-widget elementor-widget-text-editor" data-id="92edea3" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2><b>輸出指令：print() 的核心與細節</b></h2><p><span style="font-weight: 400;">print() 是 Python 中最基礎的指令，用於將資訊顯示在螢幕（終端機）上，最簡易的輸出純文字的方式。在有圖形化介面(UI)的軟體上，print的輸出往往會隱藏在軟體執行的後台，不會讓一般使用者看到，留給軟體工程師除錯用的。</span></p><h3><b>基本語法規則</b></h3><ul><li style="font-weight: 400;" aria-level="1"><b>全小寫</b><span style="font-weight: 400;">：Python 對大小寫敏感，必須寫成 print，寫成 Print 會報錯。</span></li><li style="font-weight: 400;" aria-level="1"><b>括號</b><span style="font-weight: 400;">：函式後方必須加上 ()。</span></li><li style="font-weight: 400;" aria-level="1"><b>內容</b><span style="font-weight: 400;">：可以是文字（需加引號）、數字、變數或運算結果。</span></li></ul>								</div>
				</div>
				<div class="elementor-element elementor-element-9a5ba7b elementor-widget elementor-widget-code-block-for-elementor" data-id="9a5ba7b" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 正確寫法
print(&quot;Hello, world!&quot;)  # 讓電腦顯示文字
print(123)              # 顯示數字

# 常見錯誤示範
# Print(&quot;Error&quot;)  &lt;-- 錯誤：指令首字不能大寫</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-f8ef658 elementor-widget elementor-widget-text-editor" data-id="f8ef658" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p><span style="font-size: 14pt; font-family: 'Google Sans', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">控制換行與特殊符號</span></p><p dir="ltr" style="line-height: 1.3799999713897704; margin-top: 0pt; margin-bottom: 6pt;"><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">預設情況下，Python的print() 結束後會自動換行。我們可以透過參數調整這個行為。</span></p><ul><li><span id="docs-internal-guid-1b0cc752-7fff-e7ff-051a-80064dc5bceb"><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">取消換行 (end)：</span></span>告訴 Python 結束時不要換行，而是接上指定的字串（如空字串）。</li></ul>								</div>
				</div>
				<div class="elementor-element elementor-element-1b62eab elementor-widget elementor-widget-code-block-for-elementor" data-id="1b62eab" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>print(&quot;A&quot;, end=&quot;&quot;)
print(&quot;B&quot;)
# 輸出結果為：AB</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-3850731 elementor-widget elementor-widget-text-editor" data-id="3850731" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<ul><li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">跳脫字元 (Escape Characters)：</span><span style="font-weight: 400;"><br /></span><span style="font-weight: 400;">通常反斜線 \ 加上特定字元會有特殊功能，例如 </span><span style="font-weight: 400;">\n 代表換行(New Line)，如果要特別顯示出系統保留功能的特定文字，則需要透過跳脫字元的做法，來顯示出「\」等有特殊功能的符號本體。<br />寫法是用【\+想顯示的具有功能的保留文字】</span></li></ul>								</div>
				</div>
				<div class="elementor-element elementor-element-63a6be5 elementor-widget elementor-widget-code-block-for-elementor" data-id="63a6be5" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>print(&quot;我換行了\n\n\n&quot;)  # \n 代表換行 (New Line)
print(&quot;\\&quot;)              # 顯示反斜線 \ 本身
print(&quot;\&quot;&quot;)              # 顯示雙引號 &quot; 符號</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-7b0ce6a elementor-widget-divider--view-line elementor-widget elementor-widget-divider" data-id="7b0ce6a" data-element_type="widget" data-e-type="widget" data-widget_type="divider.default">
				<div class="elementor-widget-container">
							<div class="elementor-divider">
			<span class="elementor-divider-separator">
						</span>
		</div>
						</div>
				</div>
				<div class="elementor-element elementor-element-9ec22b5 elementor-widget elementor-widget-text-editor" data-id="9ec22b5" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2 dir="ltr" style="line-height: 1.3799999713897704; margin-top: 6pt; margin-bottom: 6pt;"><span style="font-size: 18pt; font-family: 'Google Sans', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">變數 (Variable)：資料的「抽屜」</span></h2><h3 dir="ltr" style="line-height: 1.3799999713897704; margin-top: 0pt; margin-bottom: 6pt;"><span style="font-size: 14pt; font-family: 'Google Sans', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">變數概念</span></h3><ul style="margin-top: 0; margin-bottom: 0; padding-inline-start: 48px;"><li dir="ltr" style="list-style-type: disc; font-size: 11pt; font-family: Arial, sans-serif; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space: pre; margin-left: -12.75pt;" aria-level="1"><p dir="ltr" style="line-height: 1.3799999713897704; margin-top: 0pt; margin-bottom: 0pt;" role="presentation"><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">定義</span><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">：變數就像是一個「抽屜」，專門用來存放資料（如數字、文字）。</span></p></li><li dir="ltr" style="list-style-type: disc; font-size: 11pt; font-family: Arial, sans-serif; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space: pre; margin-left: -12.75pt;" aria-level="1"><p dir="ltr" style="line-height: 1.3799999713897704; margin-top: 0pt; margin-bottom: 6pt;" role="presentation"><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">賦值 (=)</span><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">：在程式中，單一個等號 = 代表「賦值」，意思是</span><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">把右邊的資料，放進左邊的變數儲存</span><span style="font-size: 11pt; font-family: 'Google Sans Text', sans-serif; color: #1f1f1f; background-color: transparent; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; text-wrap-mode: wrap;">。</span></p></li></ul><h3 dir="ltr" style="line-height: 1.3799999713897704; margin-top: 6pt; margin-bottom: 6pt;"><span style="font-size: 14pt; font-family: 'Google Sans', sans-serif; color: #1f1f1f; background-color: transparent; font-weight: bold; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-variant-position: normal; font-variant-emoji: normal; vertical-align: baseline; white-space-collapse: preserve;">命名與使用</span></h3><p data-pm-slice="1 1 [&quot;blockquote&quot;,{}]">雖然後期版本的 Python 允許使用中文變數名稱（例如 <code>名字="龍龍"</code>），但在實務開發中<strong>強烈不建議</strong>這樣寫。這容易導致編碼問題造成非預期的結果或錯誤，即使可以運作，但在不同的電腦環境下，有高機率會無法執行，請養成使用英文命名變數的習慣。</p><p data-pm-slice="1 1 [&quot;blockquote&quot;,{}]">強烈建議即使是入門學習，也養成<strong>不要用 a、b、c 這類簡易的變數名稱</strong>，養成習慣後，在程式碼寫到超過一百行時，將會很難除錯，也很難與他人合作 (我看過傳承超過十年的系統原始碼都是abc，真的會逼死人&#8230;)</p>								</div>
				</div>
				<div class="elementor-element elementor-element-306465c elementor-widget elementor-widget-code-block-for-elementor" data-id="306465c" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 定義變數
name = &quot;龍龍&quot;  # 文字類（字串），前後都要加雙引號
age = 18       # 數字類（整數），不需要加引號

# 使用變數
print(name)    # 印出：龍龍
print(age)     # 印出：18
print(f&quot;你好，我是{name}，今年{age}歲&quot;)  #印出：我是龍龍，今年18歲</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-44e571c elementor-widget-divider--view-line elementor-widget elementor-widget-divider" data-id="44e571c" data-element_type="widget" data-e-type="widget" data-widget_type="divider.default">
				<div class="elementor-widget-container">
							<div class="elementor-divider">
			<span class="elementor-divider-separator">
						</span>
		</div>
						</div>
				</div>
				<div class="elementor-element elementor-element-0c3cc61 elementor-widget elementor-widget-text-editor" data-id="0c3cc61" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<h2 data-pm-slice="1 1 []">使用者互動：<code>input()</code></h2><p data-pm-slice="1 1 []">讓程式不再只是單向輸出，而是能接收使用者的指令。</p><h3 data-pm-slice="1 1 []">基本語法</h3><ul><li><p><strong>語法</strong>：<code>input("提示文字")</code></p></li><li><p><strong>特性</strong>：<code>input</code> 接收到的資料，預設型別永遠是 <strong>字串 (String)</strong>。</p></li></ul><h3>實戰範例</h3>								</div>
				</div>
				<div class="elementor-element elementor-element-b666788 elementor-widget elementor-widget-code-block-for-elementor" data-id="b666788" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 1. 顯示提示並等待輸入，將結果存入變數 name
name = input(&quot;請輸入你的名字:&quot;)

# 2. 再次等待輸入，存入變數 age_input
age_input = input(&quot;請輸入你的年齡:&quot;)

# 3. 結合變數進行輸出
print(f&quot;你的名字是{name}&quot;)
print(f&quot;{name}是{age_input}歲，聰明的人&quot;)</code></pre>				</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[Python入門教學] if, elif, else 是什麼?</title>
		<link>https://dragongo.co/python%e5%85%a5%e9%96%80%e6%95%99%e5%ad%b8-if-elif-else-%e6%98%af%e4%bb%80%e9%ba%bc/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Mon, 18 Aug 2025 14:49:58 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[新手教學]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=2443</guid>

					<description><![CDATA[記錄一下這次上課的內容，供上課的夥伴或補課的夥伴&#8230;]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="2443" class="elementor elementor-2443">
						<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-e48df61 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="e48df61" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-ea3f5c2" data-id="ea3f5c2" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-0849ca1 elementor-widget elementor-widget-text-editor" data-id="0849ca1" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>記錄一下這次上課的內容，供上課的夥伴或補課的夥伴做複習使用。這次上課主要是針對布林資料型態還有 if else 來做一個範例程式。</p><p>首先講一下這個範例程式大概在做的功能。它會先問使用者分數，當你輸入分數進去之後，它會顯示布林值，判斷這個分數是否大於等於60。如果大於等於60，它就會顯示及格；如果小於60，它就會顯示不及格，並 print 不及格的部分。</p><p>這邊有幾個要注意的點：<br />第一個是 if 和 else，當 if 和 else 出現時，它們是在 python 裡面保留的關鍵字，是專門用來做指令的。後面會用一個條件句，如 score 大於等於60，然後冒號後面的下一行是要執行的命令，如果今天我的指令要包在 if 條件句裡面，就需要在下一行的指令中縮排。比較推薦用 tab 鍵快速縮排，再透過 shift 加 tab 鍵快捷鍵減少縮排。不建議用空白鍵和刪除鍵，因為空白鍵難以判斷縮排的間隔是否正確。</p>								</div>
				</div>
				<div class="elementor-element elementor-element-e3dc87c elementor-widget elementor-widget-code-block-for-elementor" data-id="e3dc87c" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>#bool Boolean 布林 -&gt; 是/否 True/False

score = int(input(&quot;分數？&quot;))

# 先看bool result結果
# score &gt;= 60 scroe有沒有大於等於60?

print(&quot;boolean：&quot;, score &gt;= 60)

# 再轉成人類可讀
if score &gt;= 60: #如果score有沒有大於等於60: 做以下的事情
  print(&quot;及格！<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f389.png" alt="🎉" class="wp-smiley" style="height: 1em; max-height: 1em;" />&quot;)
else: #否則: 做以下的事情
  print(&quot;不及格，要加油！<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4aa.png" alt="💪" class="wp-smiley" style="height: 1em; max-height: 1em;" />&quot;)

#快速縮排：tab 減少縮排shift+tab
# 不要用空白鍵，你會有一堆bug要除</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-ac15126 elementor-widget elementor-widget-text-editor" data-id="ac15126" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p><span style="color: inherit; font-family: inherit; font-size: inherit; font-weight: inherit; text-align: inherit;">第二部分是防止使用者輸入空白鍵。我們用 if else 的方式來做，將使用者輸入的文字透過 if 條件句判斷是否有數值。如果有數值，if 條件句為 true；如果沒有輸入任何資訊，就會進入 else，提示使用者不要輸入空白。</span></p><p>在判斷完使用者有沒有輸入分數之後，再透過 int 指令將原本輸入進來的文字轉換成整數型態，再做後續的 if else 判斷。同樣地，如果 score 大於等於60 就顯示及格，否則顯示不及格。</p>								</div>
				</div>
				<div class="elementor-element elementor-element-817b94a elementor-widget elementor-widget-code-block-for-elementor" data-id="817b94a" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>#防止使用者輸入空白鍵
score_input = input(&quot;分數？&quot;)
if score_input: #user有無輸入分數?

  score = int(score_input) #轉成整數

  print(&quot;boolean：&quot;, score &gt;= 60)
  if score &gt;= 60: #如果score有沒有大於等於60: 做以下的事情
    print(&quot;及格！<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f389.png" alt="🎉" class="wp-smiley" style="height: 1em; max-height: 1em;" />&quot;)
  else: #否則: 做以下的事情
    print(&quot;不及格，要加油！<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4aa.png" alt="💪" class="wp-smiley" style="height: 1em; max-height: 1em;" />&quot;)
</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-5453af8 elementor-widget elementor-widget-text-editor" data-id="5453af8" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p style="font-size: 14px; text-align: start; font-family: Roboto, sans-serif; font-weight: 400; color: rgb(0, 0, 0);">進階版，我示範了一個 try except 寫法。這段程式碼主要用常見的 try except 寫法防止使用者輸入非預期資訊時，可以提醒使用者輸入正確數字或通知發生未知錯誤。這部分比較屬於進階內容，在這篇文章中不多贅述，只是 demo 一下這樣的程式碼可以減少看到程式 error 的機會，又能正確收到提示。</p>								</div>
				</div>
				<div class="elementor-element elementor-element-4311908 elementor-widget elementor-widget-code-block-for-elementor" data-id="4311908" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>try:
  score_input = input(&quot;分數？&quot;)
  score = int(score_input) #轉成整數
  print(&quot;boolean：&quot;, score &gt;= 60)
  if not 0 &lt;score &lt; 100:
    raise ValueError(&quot;請輸入0~100的數字&quot;)

  if score &gt;= 60: #如果score有沒有大於等於60: 做以下的事情
    print(&quot;及格！<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f389.png" alt="🎉" class="wp-smiley" style="height: 1em; max-height: 1em;" />&quot;)
  else: #否則: 做以下的事情
    print(&quot;不及格，要加油！<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4aa.png" alt="💪" class="wp-smiley" style="height: 1em; max-height: 1em;" />&quot;)

except ValueError as e:
  print(&quot;請輸入數字！&quot;)
  print(e)
except Exception as e:
  print(&quot;發生未知錯誤&quot;)</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-5e18fe0 elementor-widget elementor-widget-text-editor" data-id="5e18fe0" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>最後一部分加入了 elif 條件。如果第一個條件沒有達成，有第二、第三、第四個條件可以試。在 Python 裡面加 elif 指令，可以讓 if 條件句多加判斷不同條件。但要注意的是，如果前面的條件達成了，它就會直接執行那個條件並跳出，不再執行後面的條件子句。</p><p>以這邊的範例來講，如果 score 大於等於90 分，就顯示成績是 A；如果大於等於80 分，就顯示成績是 B；如果都不符合，就顯示不及格。</p>								</div>
				</div>
				<div class="elementor-element elementor-element-59aca42 elementor-widget elementor-widget-code-block-for-elementor" data-id="59aca42" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>score = int(input(&quot;分數？&quot;))

# 先看bool result結果
# score &gt;= 60 scroe有沒有大於等於60?


# 再轉成人類可讀
if score &gt;= 90: #如果score有沒有大於等於60: 做以下的事情
  print(&quot;成績是A！<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f389.png" alt="🎉" class="wp-smiley" style="height: 1em; max-height: 1em;" />&quot;)
elif score &gt;= 80: #else if: 否則如果(第一個條件沒達成時，判斷這個條件)
  print(&quot;成績是B！<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f389.png" alt="🎉" class="wp-smiley" style="height: 1em; max-height: 1em;" />&quot;)
else: #否則: 做以下的事情
  print(&quot;不及格，要加油！<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4aa.png" alt="💪" class="wp-smiley" style="height: 1em; max-height: 1em;" />&quot;)</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-659f753 elementor-widget elementor-widget-text-editor" data-id="659f753" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p style="font-size: 14px; text-align: start; font-family: Roboto, sans-serif; font-weight: 400; color: #000000;">記錄一下自己的心情，就像備課的碎碎念吧。其實這次上課的程式主要是用 ChatGPT 生成。因為我自己撰寫程式的深度和強度比現在入門教學高很多，所以不像大學時期教課時對 Python 理解還沒那麼多。現在講 Python 時，我會把入門、中階、進階混為一談，但實際上在程式領域中學習等級差很多。</p>
<p style="font-size: 14px; text-align: start; font-family: Roboto, sans-serif; font-weight: 400; color: #000000;">為避免自己發生這種狀況，我和 ChatGPT 對話時請它給我合適的 code 範例，不是教我怎麼寫程式或教別人，而是給我合適範例。我拿著範例來解釋和教學，避免拉太多對入門的人來講難度過多的知識點。</p>
<p style="font-size: 14px; text-align: start; font-family: Roboto, sans-serif; font-weight: 400; color: #000000;">線上直播加入多少知識點也是一個思考點。純線上直播不像實體課能知道學生反應和互動節奏，上課節奏慢很多。但線上上課好處是大家輕鬆，不像實體上課有壓力，即使沒有要考試也有實體課程的節奏壓力。而線上直播，我定調成啟發性教學，不一定要讓你成為專業工程師，而是開啟一道大門讓你覺得Python很有趣。</p>
<p style="font-size: 14px; text-align: start; font-family: Roboto, sans-serif; font-weight: 400; color: #000000;">希望來上課或看直播的人都能收穫他們想要的東西，不管是 Python 還是 ChatGPT 或只是聽我講話都可以。如果覺得文章有幫助，可以分享給需要的人，也歡迎留言讓我知道你的感想，你們的留言是我寫文章最大的動力。希望我們都能帶給彼此更好的收穫，一起共好！</p>								</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-2b3c8b1 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="2b3c8b1" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-d3e4143" data-id="d3e4143" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-28812dd elementor-widget elementor-widget-text-editor" data-id="28812dd" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>教學錄影的影片在這：</p>								</div>
				</div>
				<div class="elementor-element elementor-element-c994ac6 elementor-widget elementor-widget-video" data-id="c994ac6" data-element_type="widget" data-e-type="widget" data-settings="{&quot;youtube_url&quot;:&quot;https:\/\/www.youtube.com\/watch?v=_BVd8LpmKjo&amp;t=2s&quot;,&quot;lazy_load&quot;:&quot;yes&quot;,&quot;video_type&quot;:&quot;youtube&quot;,&quot;controls&quot;:&quot;yes&quot;}" data-widget_type="video.default">
				<div class="elementor-widget-container">
							<div class="elementor-wrapper elementor-open-inline">
			<div class="elementor-video"></div>		</div>
						</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Python超新手教學-怎麼開始Python?</title>
		<link>https://dragongo.co/how-to-start-python/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Mon, 30 Jun 2025 12:45:41 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[程式教學]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[入門教學]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=2343</guid>

					<description><![CDATA[在網路上，你會看到無數教學告訴你該怎麼寫 Pyt&#8230;]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="2343" class="elementor elementor-2343">
						<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-2cad0f2 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="2cad0f2" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-381af17" data-id="381af17" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-73c8c43 elementor-widget elementor-widget-text-editor" data-id="73c8c43" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>在網路上，你會看到無數教學告訴你該怎麼寫 Python：有人推薦 Visual Studio Code、有人推 Jupyter Notebook，還有 Colab、虛擬環境……，常常讓人不知從何開始。各方意見不一：一會兒要你安裝原生 Python，一會兒又說用 Anaconda 建立虛擬環境，步驟五花八門，到底該怎麼辦？</p><p>如果你從沒接觸過任何的程式語言，想玩玩看寫程式，我會建議：先別急著安裝任何軟體，直接使用 Google Colab 練習。只要有一組 Google 帳號，就能馬上在瀏覽器裡撰寫並執行程式。寫程式並不怎麼高大上，先試試這一行：</p><p><!-- notionvc: 631a0479-3eb1-463c-b7fb-91876b71a905 --></p>								</div>
				</div>
				<div class="elementor-element elementor-element-97953fb elementor-widget elementor-widget-code-block-for-elementor" data-id="97953fb" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>print(&quot;Hello Wrold&quot;)</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-ce0d940 elementor-widget elementor-widget-text-editor" data-id="ce0d940" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>按下執行鍵，如果畫面出現 &#8220;Hello World&#8221;，恭喜你，已經踏入程式世界了！</p><p>那麼，什麼時候該考慮更換開發環境？當你覺得 Colab 不夠靈活，比如：</p><ol><li>你的專案有多個檔案，需要更好的檔案管理。</li><li>不希望程式碼儲存在 Google 雲端硬碟。</li><li>想在本機端或其他伺服器上執行，並且對資料安全有更高需求。</li><li>你需要安裝特殊套件或進行 AI 訓練，Colab 資源有限。</li></ol><p>如果上述情況出現，再考慮安裝本地 Python 與 IDE（例如 VS Code）或建立虛擬環境也不遲。</p><p>對於初學者的你而言，最重要的是以「<strong>最快、最簡單</strong>」的方式開始動手，而不是先被複雜的安裝設定絆住腳步。享受程式帶來的樂趣，才是學習的動力。</p><hr /><p>現在，就花三分鐘，點擊這個<a href="https://colab.research.google.com/" target="_blank" rel="noopener">連結</a>，在 Colab 中複製並執行這行程式：<code class="language-python"></code></p><p><!-- notionvc: 631a0479-3eb1-463c-b7fb-91876b71a905 --></p>								</div>
				</div>
				<div class="elementor-element elementor-element-7dbbc42 elementor-widget elementor-widget-code-block-for-elementor" data-id="7dbbc42" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>print(&quot;Hello Wrold&quot;)</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-89e141f elementor-widget elementor-widget-text-editor" data-id="89e141f" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<blockquote><p><strong>一起玩程式吧！</strong></p></blockquote>								</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>何謂Python的Type Hint？（推薦有幫助到我的教學網站）</title>
		<link>https://dragongo.co/%e4%bd%95%e8%ac%82python%e7%9a%84type-hint%ef%bc%9f%ef%bc%88%e6%8e%a8%e8%96%a6%e6%9c%89%e5%b9%ab%e5%8a%a9%e5%88%b0%e6%88%91%e7%9a%84%e6%95%99%e5%ad%b8%e7%b6%b2%e7%ab%99%ef%bc%89/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Wed, 19 Jun 2024 12:23:00 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Type Hint]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=2312</guid>

					<description><![CDATA[在寫Python到一定程度後，到底該如何減少因為資料型態誘發的程式錯誤？]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="2312" class="elementor elementor-2312">
						<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-d51d4b5 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="d51d4b5" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-bd5760e" data-id="bd5760e" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-44fec49 elementor-widget elementor-widget-heading" data-id="44fec49" data-element_type="widget" data-e-type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
					<h2 class="elementor-heading-title elementor-size-default">何謂Type Hint？</h2>				</div>
				</div>
				<div class="elementor-element elementor-element-43f0b3d elementor-widget elementor-widget-text-editor" data-id="43f0b3d" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>Python之所以會很推薦是入門語言的關係，是因為它不像C語言這種靜態語言，需要明確定義變數的資料型態，像是int(整數)、string(字串)、dict(字典)，當你要讓第一行程式碼啟動時，你需要先搞懂基礎的資料型態，才能執行顯示文字出來的功能，在新手入門階段增加了一點門檻，故現在較推薦初學者學的第一個語言為Python這種動態語言。</p><p>但當我逐漸對Python有越來越深刻的認識，撰寫大大小小的程式專案，我發現動態語言的好處在於不用定義變數就能使用，但壞處也是我會一直遇到Bug或Error卡在一些特殊的變數上，特別是我有用模組的情況下，更容易「誤解」變數的資料型態，例如我今天以為這個變數是數值，所以拿去做運算，但實際上此變數只是字串型態，不可以做運算，就會發生錯誤。</p>								</div>
				</div>
				<div class="elementor-element elementor-element-f5c4f68 elementor-widget elementor-widget-code-block-for-elementor" data-id="f5c4f68" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'># 簡單的加法運算，使用型別註解
def add_numbers(a: int, b: int) -&gt; int:
    return a + b

result = add_numbers(5, &quot;3&quot;)  # 這裡會發生錯誤
print(&quot;Sum:&quot;, result)</code></pre>				</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-82805c2 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="82805c2" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4fba30e" data-id="4fba30e" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-8ddfc85 elementor-widget elementor-widget-heading" data-id="8ddfc85" data-element_type="widget" data-e-type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
					<h2 class="elementor-heading-title elementor-size-default">如何撰寫Type Hint？</h2>				</div>
				</div>
				<div class="elementor-element elementor-element-234c8e4 elementor-widget elementor-widget-text-editor" data-id="234c8e4" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>因此建議在Python中撰寫到一定的程度後，可以嘗試看看加入Type hint，能協助你在開發程式的過程中，確認變數的型態，在撰寫程式時減少遇到Error的機會，而Type hint的基礎寫法就是在變數後面加入「：」來表示它的變數型態。</p>
<p>而在定義函數後面加入「-&gt;」再加上變數類別，代表那個函數return會是哪一種資料類別。以上面的程式碼作為範例，在「add_numbers」函數結束後，返回的資料型態為整數(int)。</p>								</div>
				</div>
				<div class="elementor-element elementor-element-0aed0f9 elementor-widget elementor-widget-code-block-for-elementor" data-id="0aed0f9" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-python'>a = 1
b = 2
print(a+b)
#=================
# 有Type Hint
a: int = 1
b: int = 2
print(a+b) # output 2</code></pre>				</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				<section class="penci-section penci-disSticky penci-structure-10 elementor-section elementor-top-section elementor-element elementor-element-f9158f3 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="f9158f3" data-element_type="section" data-e-type="section">
						<div class="elementor-container elementor-column-gap-default">
					<div class="penci-ercol-100 penci-ercol-order-1 penci-sticky-ct    elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-492ea26" data-id="492ea26" data-element_type="column" data-e-type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-8fe6c07 elementor-widget elementor-widget-heading" data-id="8fe6c07" data-element_type="widget" data-e-type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
					<h2 class="elementor-heading-title elementor-size-default">關於Type hint的相關文章</h2>				</div>
				</div>
				<div class="elementor-element elementor-element-e1fc6a4 elementor-widget elementor-widget-text-editor" data-id="e1fc6a4" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>網路上其實對於Type hint的教學文章有蠻多的，在這邊提供當年對我很有用的幾個網站供你學習和參考。</p><p>入門的Type hint教學：<a href="https://haosquare.com/python-type-hints-3-beginner-mistakes/#Optional_%E5%9C%A8%E5%8F%AF%E8%AE%8A%E5%BC%95%E6%95%B8%E7%9A%84%E5%A5%BD%E8%99%95" target="_blank" rel="noopener">Python Type Hints 教學：我犯過的 3 個菜鳥錯誤</a></p><p>另外當年困擾我很久在Type Hint中的AnyType和Optional用法，我覺得這幾個網站有幫助我理解。</p><p>Any Type（定義宣告為任意數值都可輸入）：<a href="https://docs.python.org/3/library/typing.html#the-any-type" target="_blank" rel="noopener">https://docs.python.org/3/library/typing.html#the-any-type</a></p><p>Optional（代表這個變數是可選擇性輸入的，可以選擇不輸入該變數）：「<a style="font-family: inherit; font-size: inherit; font-weight: inherit; text-align: inherit;" href="https://www.ithome.com.tw/voice/148136" target="_blank" rel="noopener">型態提示、重載與Optional</a>」、「<a style="font-family: inherit; font-size: inherit; font-weight: inherit; text-align: inherit;" href="https://stackoverflow.com/questions/51710037/how-should-i-use-the-optional-type-hint" target="_blank" rel="noopener">Stack Overflow: How should I use the Optional type hint?</a>」</p><p> </p><p> </p>								</div>
				</div>
					</div>
		</div>
					</div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[ChatGPT]如何用AI幫你加速開發程式(開發XX功能)</title>
		<link>https://dragongo.co/chatgpt%e5%a6%82%e4%bd%95%e7%94%a8ai%e5%b9%ab%e4%bd%a0%e5%8a%a0%e9%80%9f%e9%96%8b%e7%99%bc%e7%a8%8b%e5%bc%8f%e9%96%8b%e7%99%bcxx%e5%8a%9f%e8%83%bd/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Sun, 25 Jun 2023 15:22:37 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[人生の紀錄]]></category>
		<category><![CDATA[程式教學]]></category>
		<category><![CDATA[自我成長]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[ChatGPT]]></category>
		<category><![CDATA[python]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=1932</guid>

					<description><![CDATA[到底要如何讓ChatGPT對程式問題回答好一點答案？
最近一直在寫碩士論文，真的是瘋狂用ChatGPT在輔助我開發程式，而這邊就分享幾個我自己是如何在用ChatGPT輔助和加速我開發程式。]]></description>
										<content:encoded><![CDATA[<p>距離上一篇有關ChatGPT的<a href="https://dragongo.co/chatgpt%e7%94%a8ai%e5%b9%ab%e4%bd%a0%e6%89%be%e7%a0%94%e7%a9%b6%e8%b3%87%e6%96%99/" data-type="URL" data-id="https://dragongo.co/chatgpt%e7%94%a8ai%e5%b9%ab%e4%bd%a0%e6%89%be%e7%a0%94%e7%a9%b6%e8%b3%87%e6%96%99/">文章</a>也有好幾個月了，現在ChatGPT不斷的在更新與進化，最近ChatGPT4也開放給付費者使用，而我就是那一個其中的付費者了，畢竟我最近一直在寫碩士論文，真的是瘋狂用ChatGPT在輔助我開發程式，而這邊就分享幾個我自己是如何在用ChatGPT輔助和加速我開發程式。</p>
<h2 class="wp-block-heading">情境：我要寫XX程式語言的XX功能~</h2>
<h3 class="wp-block-heading">懶人包重點整理（看完別走<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f622.png" alt="😢" class="wp-smiley" style="height: 1em; max-height: 1em;" />）</h3>
<ul class="wp-block-list">
<li>詢問的問題要定義的越詳細越好</li>
<li>將一個表面的問題，先自己拆解這個問題問得更詳細（給你幾個問題方向參考）
<ul class="wp-block-list">
<li>要用哪個程式語言語言解決這個問題？</li>
<li>要用哪個函式庫？</li>
<li>輸入資料有沒有更具體的解釋？</li>
<li>輸出資料有沒有更具體的解釋？</li>
<li>能不能把這個問題拆解成更詳細的步驟？</li>
<li>設計這個問題的目的是甚麼？</li>
</ul>
</li>
<li>問ChatGPT問題前，一定要下相對應的ChatGPT指令，會大幅度提升回答品質（千萬不要小看這個！）</li>
<li>越簡單的問題，越容易在簡短的問題中回答出正確答案，但越複雜的問題，就不一定會有正確答案了。（這之後的文章再來好好說明）</li>
</ul>
<p>不管在寫哪個程式語言，常會遇到要開發新功能，可能會用到新的函式庫或舊有的函式庫，而在以前就必須要去那個函式庫的官方網站，看官方出的手冊和有沒有其他人給的部落格教學文（就像小弟我在亂寫的文章），若有中文就算了，但很多時候九成以上的資料都英文，而且還有真假難辨的資料。</p>
<p>舉個例子：「我想要寫一個可以把csv檔案讀入進python程式語言做使用」。很多時候往往會就停留在這邊就結束了，但這個例子所要的功能並沒有很確定，像是csv檔案是大數據規模的嗎？檔案大小有多大？有幾個欄位的資料（只有五個欄位和有五千萬個欄位的csv檔案差很多&#8230;，<s>然後不要問我五千萬個欄位怎麼</s>讀），這些需求要更詳細的定義，不管在問ChatGPT還是在解決程式問題時，才會更加容易。</p>
<p>重新定義問題：「我想要寫一個可以把csv檔案讀入進python程式語言做使用，csv檔案會是複合型資料，大概有七八個欄位，幾十萬行的數據資料，檔案大小不超過1GB，讀入的資料型態會需要多種形態」，那假設我是程式小白，我連函式庫都不知道怎麼選用，還是要自己寫的情況，問一下ChatGPT。</p>
<p>問ChatGPT的技巧，要先在問題前面加入提示指令，很推薦這篇<a href="https://www.explainthis.io/zh-hant/chatgpt" data-type="URL" data-id="https://www.explainthis.io/zh-hant/chatgpt" target="_blank" rel="noreferrer noopener">ChatGPT指令大全</a>、ChatGPT Prompt : 各職業詠唱大全(超過100個案例)這些文章，那我在這邊下的提示指令是：「你現在是python專家，請針對我的問題提出建議，我的問題是：&#8230;&#8230;.」，在後面接上剛剛定義更清楚的問題後，順便在要求ChatGPT「跟我說明有哪些函式庫和指令可以使用、給我更多不同的解答方案」，最後他就給我這一長串的答案，<s>而且答案都是正確的了&#8230;導致我後面要講的內容都不用講了QAQ</s>，像是如果ChatGPT的答案都不給正確時，有甚麼辦法？這就留待到後面來說了，順便附上這段問答紀錄的<a href="https://chat.openai.com/share/8672c625-20c1-4cc1-811b-5d5a61424347" data-type="URL" data-id="https://chat.openai.com/share/8672c625-20c1-4cc1-811b-5d5a61424347" target="_blank" rel="noreferrer noopener">網址</a>給你參考，也可以玩一下</p>
<div class="wp-block-image">
<figure class="aligncenter size-large"><img fetchpriority="high" decoding="async" width="732" height="1024" src="https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-224455-732x1024.png" alt="ChatGPT 2023 06 25 224455" class="wp-image-1934" title="[ChatGPT]如何用AI幫你加速開發程式(開發XX功能) 1" srcset="https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-224455-732x1024.png 732w, https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-224455-214x300.png 214w, https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-224455-768x1074.png 768w, https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-224455-1098x1536.png 1098w, https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-224455-1464x2048.png 1464w, https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-224455-1140x1595.png 1140w" sizes="(max-width: 732px) 100vw, 732px" /></figure>
</div>
<p>同場加映一下當問ChatGPT前面定義不清楚的問題時，他給我的答案，可以看的出來，當問題給得越完整和複雜時，ChatGPT給予的回答長度會越長而且品質也相對較好。</p>
<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img decoding="async" width="1024" height="600" src="https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-225450-1024x600.png" alt="ChatGPT 2023 06 25 225450" class="wp-image-1936" style="width:732px;height:429px" title="[ChatGPT]如何用AI幫你加速開發程式(開發XX功能) 2" srcset="https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-225450-1024x600.png 1024w, https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-225450-300x176.png 300w, https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-225450-768x450.png 768w, https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-225450-1536x900.png 1536w, https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-225450-2048x1201.png 2048w, https://dragongo.co/wp-content/uploads/2023/06/ChatGPT_2023_06_25-225450-1140x668.png 1140w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>
<h3 class="wp-block-heading">附上我問ChatGPT範例的問題文字給你複製使用</h3>
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>你現在是python專家，請針對我的問題提出建議，我的問題是：「我想要寫一個可以把csv檔案讀入進python程式語言做使用，csv檔案會是複合型資料，大概有七八個欄位，幾十萬行的數據資料，檔案大小不超過1GB，讀入的資料型態會需要多種形態」，請推薦我可以做到這個csv檔案讀入進puython的函式庫，以及相關的指令，可以的話，給我多個解答方法的選項</p>
</blockquote>
<p>以上就是入門階段時我所用過的方法，分享給你，也歡迎你在下面留言區理性討論和給予指教，若要轉載此文章，請標明出處喔～</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>[新手必學]如何將問題與需求轉換為程式碼(只需要懂1+1就可以懂！)</title>
		<link>https://dragongo.co/%e6%96%b0%e6%89%8b%e5%bf%85%e5%ad%b8%e5%a6%82%e4%bd%95%e5%b0%87%e5%95%8f%e9%a1%8c%e8%88%87%e9%9c%80%e6%b1%82%e8%bd%89%e6%8f%9b%e7%82%ba%e7%a8%8b%e5%bc%8f%e7%a2%bc%e5%8f%aa%e9%9c%80%e8%a6%81/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Sat, 11 Mar 2023 08:52:14 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[程式教學]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[新手必學]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=1917</guid>

					<description><![CDATA[你是否常常會有困惑，為什麼我看到一個程式問題時，老師都說那個憑「直覺」，就鍵盤打一打...默默的把題目寫完，好，當我看著老師的程式和問題，我都理解了，但蓋上程式，重新自己要寫的時後，腦袋就一片空白，不知道怎麼開始？]]></description>
										<content:encoded><![CDATA[
<p>你是否常常會有困惑，為什麼我看到一個程式問題時，老師都說那個憑「直覺」，就鍵盤打一打&#8230;默默的把題目寫完，好，當我看著老師的程式和問題，我都理解了，但蓋上程式，重新自己要寫的時後，腦袋就一片空白，不知道怎麼開始？</p>



<p>但問老師怎麼把問題或需求轉成程式時，老師只會回一句：「多寫幾次，有經驗，就會了」，有時還會被責罵，一定就是你不夠認真寫程式，所以才不會寫，這麼簡單的東西，不是應該看了就知道怎麼寫嗎？（完了…我應該不會被炎上吧？）</p>



<p>那該如何將問題轉成程式碼呢？其實會需要拆解「問題」知道問題的需求，才能進一步的開始寫。<br>舉一個小學生都會的數學問題，要改寫成程式碼。</p>



<p>題目：請寫出「輸入兩個變數，給我他的總和」。</p>



<p>不管拿到哪一種題目時，都可想幾個問題：</p>



<ol class="wp-block-list">
<li>程式輸入有什麼？</li>



<li>程式輸出有什麼？</li>



<li>輸入到輸出間，到底經歷過了什麼過程<s>陰影</s>，才可以得到輸出？</li>
</ol>



<p>以這個範例可以這樣子回答：</p>



<ol class="wp-block-list">
<li>輸入有兩個變數 </li>



<li>輸出有一個具小數或整數的數字</li>



<li>將這兩個輸入的數字相加起來，就可以得到輸出</li>
</ol>



<p>好，我相信這個邏輯應該不難吧？那緊接著就可以把這個回答，寫成一個流程圖。</p>



<figure class="wp-block-image size-full"><img decoding="async" width="961" height="916" src="https://dragongo.co/wp-content/uploads/2023/03/image.png" alt="image" class="wp-image-1918" title="[新手必學]如何將問題與需求轉換為程式碼(只需要懂1+1就可以懂！) 3" srcset="https://dragongo.co/wp-content/uploads/2023/03/image.png 961w, https://dragongo.co/wp-content/uploads/2023/03/image-300x286.png 300w, https://dragongo.co/wp-content/uploads/2023/03/image-768x732.png 768w" sizes="(max-width: 961px) 100vw, 961px" /></figure>



<p>有流程圖後<s>抱歉字很醜…</s>，就可以開始撰寫程式碼啦，當這個時候有哪個步驟不會寫時，就是用那個步驟的關鍵字去找google，就更容易找到你看得懂的答案，以及透過拆解步驟的方式，你可以更清楚知道自己在做什麼？</p>



<p>例如：我不知道怎麼寫python的輸入變數，那可以google「python 輸入變數 教學」的關鍵字。</p>



<pre><code class="python">var1 = float(input("請輸入變數1"))  # 輸入變數1
var2 = float(input("請輸入變數2"))  # 輸入變數2
result = var1 + var2  #  將兩個變數相加
print(result)  # 輸出結果
</code></pre>



<p>以上就是我自己統整我如何拆解「問題與需求」，最終將它變成程式碼的過程。</p>



<p>下一章，將會進階一點的題目【猜數字1A2B】遊戲，要如何去從題目，轉換成程式流程，並且寫成正確的程式碼！</p>



<p>延伸閱讀：<a href="https://hsuchihting.github.io/Learning-Experience/20210127/1279212541/" target="_blank" rel="noopener">如何把想法轉成程式碼? | TimCodingBlog (hsuchihting.github.io)</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>免費的Python自學資源</title>
		<link>https://dragongo.co/%e5%85%8d%e8%b2%bb%e7%9a%84python%e8%87%aa%e5%ad%b8%e8%b3%87%e6%ba%90/</link>
		
		<dc:creator><![CDATA[龍冥]]></dc:creator>
		<pubDate>Sat, 26 Jun 2021 03:35:01 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[程式教學]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[程式自學]]></category>
		<category><![CDATA[自學資源]]></category>
		<guid isPermaLink="false">https://dragongo.co/?p=1553</guid>

					<description><![CDATA[我平常學習Python會用這些資源，在此統整外，也提供給你學習的管道OwO]]></description>
										<content:encoded><![CDATA[
<p>我平常學習Python會用這些資源，在此統整外，也提供給你學習的管道OwO</p>



<h2 class="has-text-align-center wp-block-heading" id="A">Google查詢</h2>



<p>很多Python的問題我都會透過Google查詢，例如我今天要查Python的printf怎麼用，我就會透過「Python+空格+問題」上google查詢，在google搜尋列裡面兩個關鍵字中間加入一個空格，google就會搜尋資料裡面有這兩個關鍵字的資料優先出來，所以要查Python的printf怎麼用，我就會用「Python printf 教學」的關鍵字下去查。</p>



<p>大多數的Python基礎問題都可以透過Google找到，除了一般的教學網站外，切記google是一個非常強大的老師，通常只有你不曉得怎麼在Google上分析出你要的資料，不會是Google沒有這個資料。</p>



<hr class="wp-block-separator"/>



<h2 class="has-text-align-center wp-block-heading" id="B">教學網站</h2>



<h3 class="wp-block-heading"><a href="https://lidemy.com/p/alg101-leetcode" data-type="URL" data-id="https://lidemy.com/p/alg101-leetcode" target="_blank" rel="noreferrer noopener">先別急著寫 leetcode</a></h3>



<p>此教學資源很適合給新手，此教材會教以下這幾點</p>



<ol class="wp-block-list"><li>充當人體編譯器，以電腦的思維模式去看程式碼</li><li>在寫程式碼以前，先把解法用白話文或是虛擬碼寫出來</li><li>仔細觀察題目內容以及輸入範圍</li><li>熟悉迴圈、判斷式、函式以及其他程式基礎語法的使用</li><li>實作內建函式增加對語法熟悉度</li><li>練習大量程式基礎題，直到你覺得這些題目超簡單為止</li></ol>



<p>很適合給對於有學過程式，但看到題目或問題卻還是常常想不到邏輯的人看</p>



<h3 class="wp-block-heading"><a href="https://mofanpy.com/" target="_blank" data-type="URL" data-id="https://mofanpy.com/" rel="noreferrer noopener">莫煩Python</a></h3>



<p>裡面從新手開始教，優點是每章節都很短，需要看的時間不長，但其缺點是偏向新手教學，所以每個例子或是範例其實都較淺、不深入，適合新手、對Python不熟或是想初步了解該模組的人用。</p>



<p>另外他的內容範圍很廣，有新手教學、機器學習、數據處理、網頁爬蟲等，一大堆，所以推薦給想要初步了解的人看。</p>



<p>從新手教起的（交互式學習）：<a href="https://mofanpy.com/tutorials/python-basic/interactive-python/" target="_blank" rel="noreferrer noopener">https://mofanpy.com/tutorials/python-basic/interactive-python/</a></p>



<p>爬蟲網頁：<a href="https://mofanpy.com/tutorials/data-manipulation/scraping/" target="_blank" rel="noreferrer noopener">https://mofanpy.com/tutorials/data-manipulation/scraping/</a></p>



<h3 class="wp-block-heading"><a href="https://rainforest2019.blogspot.com/" target="_blank" data-type="URL" data-id="https://rainforest2019.blogspot.com/" rel="noreferrer noopener">雨林數位學苑</a></h3>



<p>此網站通常在寒暑假的時候會釋放免費的網路課程可以報名(有國小、國中)，會由溫教授在google classroom上面做非同步的教學，教學內容很完整、有系統性。</p>



<p>裡面有Python、Scratch、Micro.bit的線上免費教學課程，偶爾也會有比賽資訊可報名。</p>



<hr class="wp-block-separator"/>



<h2 class="has-text-align-center wp-block-heading" id="C">題庫網站</h2>



<h3 class="wp-block-heading"><a href="http://khcode.m-school.tw/index.php" target="_blank" data-type="URL" data-id="http://khcode.m-school.tw/index.php" rel="noreferrer noopener">高雄市高中職學生 &#8211; &#8220;飆程式網&#8221;</a>、程式城計畫<strong>&nbsp;&#8211; 數科平台</strong></h3>



<p>數科平台的前身就是飆程式網，此網站很適合新手入門，他設計給國中生學習程式，優點是題目有難易度分級，但缺點是網站平台有些漏洞，帳號密碼要記好，因為沒有找回密碼的功能，好像也沒有連絡後台的辦法。</p>



<p>除此之外，這網站的有一些題目也會不知道該怎麼解，google無法查到他的正解，我有空會將我在題庫上寫出的參考答案放到網誌上，與大家一起討論。</p>



<h3 class="wp-block-heading"><a href="https://zerojudge.tw/" target="_blank" data-type="URL" data-id="https://zerojudge.tw/" rel="noreferrer noopener">高中生程式解題系統</a></h3>



<p>此解題平台是設計給高中職的學生做，但裡面也有些題目適合新手或是國中生做，但壞處是他裡面的題目分級不明確，要一題一題慢慢找，偶爾會遇到題目設計的不夠嚴謹的情況發生，但優點是底下討論區，有的時候會有大神在下面幫忙指引解題的道路。</p>



<p>此平台從新手到比賽的題目都有，只要肯花時間在裡面找題目做，也能增強程式功力。</p>



<h3 class="wp-block-heading"><a href="https://leetcode.com/problemset/all/" target="_blank" data-type="URL" data-id="https://leetcode.com/problemset/all/" rel="noreferrer noopener">LeetCode</a></h3>



<p>相信有在「刷題」的人一定都知道這個網站，他是一個專業的題庫網站，其優點是題目難易度分級明確，可以在上面訓練不同的演算法，鍛鍊自己的程式邏輯的一個聖地，但是他對英文閱讀需要一定的門檻，裡面是全英文敘述，大部分的題目都會有許多大神在上面分享自己的作法、提示或是想法，是個訓練程式基本功的好地方。</p>



<p>不推薦程式新手去寫這邊的題目，因為他的Easy最簡單的題目，其實就有一定的難度，需要對於程式有一定基礎功的人上去做，才不至於太挫折。</p>



<p>順帶一題，筆者我本身有上去做過一題，但後來發現題目對我來說太難&#8230;所以我就沒有做那裏的題庫了，他適合資工系的人去玩＞﹏＜，我的強項還是在寫微處理機，因此純粹的演算法我接觸的還是不夠多。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
