HW03 115103108
2.https://youtube.com/shorts/mr1N_DUXsB4?feature=share
3.學習卡 測驗
4.寫1個程式需附加說明 Create a README For Github
# 個位數為 5 的平方計算程式
## 專案介紹
這是一個使用 Python 編寫的簡單程式,可以計算個位數為 5 的整數平方。
如果輸入的數字個位數不是 5,程式就會顯示錯誤提示訊息。
## 功能特色
- 讓使用者輸入一個整數。
- 判斷數字的個位數是否為 5。
- 如果個位數為 5,計算並顯示平方。
- 如果個位數不是 5,顯示提示訊息。
## 開發環境
- Python 3.x
- 不需要安裝額外的套件。
## 程式碼
n = int(input('Enter the number: '))
if n % 10 == 5:
print('Square:', n, '*', n, '=', n * n)
else:
print('Please Enter correct number having LSB 5')
## 執行範例一
輸入:
Enter the number: 43
輸出:
Please Enter correct number having LSB 5
## 執行範例二
輸入:
Enter the number: 75
輸出:
Square: 75 * 75 = 5625
## 程式原理
- n % 10:取得數字的個位數。
- n % 10 == 5:判斷個位數是否為 5。
- n * n:計算數字的平方。
- if-else:根據判斷結果執行不同的程式。
## 執行方式
1. 將程式碼儲存為 square_ending_in_5.py。
2. 開啟終端機。
3. 輸入以下指令執行程式:
python3 square_ending_in_5.py
## 專案目的
本專案適合 Python 初學者練習以下基礎概念:
- 使用者輸入
- 條件判斷
- 算術運算
- 輸出結果
## 授權說明
本專案可供個人學習與教育用途使用。

留言
張貼留言