1
notebook
https://notebook.google.com/notebook/95b351c6-6b8c-42bf-8379-f4626ca70042
2
https://studio.youtube.com/video/rLmDbh3C-xo/edit
3.
4.
🐍 Python 程式碼 (score_checker.py)
def judge_score(score, pass_standard=60):
"""
判斷成績是否及格並給予評語
:param score: 輸入的分數 (float/int)
:param pass_standard: 及格標準,預設為 60 分
:return: (is_pass, comment)
"""
# 檢查分數是否在合理範圍內
if score < 0 or score > 100:
return None, "錯誤:分數必須介於 0 到 100 之間!"
# 判斷是否及格
is_pass = score >= pass_standard
# 根據分數給予評語
if score >= 90:
comment = "太棒了!表現非常優秀,請繼續保持!"
elif is_pass:
comment = "恭喜及格!代表你已經掌握了基本概念,繼續加油!"
else:
comment = "很遺憾未達及格標準。別氣餒,找出不懂的地方再接再厲!"
return is_pass, comment
# 測試主程式
def main():
print("=== 歡迎使用成績及格判斷器 ===")
try:
# 取得使用者輸入並轉換為浮點數
user_input = input("請輸入您的成績 (0-100):")
score = float(user_input)
# 呼叫判斷函數
is_pass, message = judge_score(score)
# 顯示結果
print("\n--- 判斷結果 ---")
if is_pass is None:
print(message)
else:
status = "【及格】" if is_pass else "【不及格】"
print(f"您的分數:{score} 分")
print(f"及格狀態:{status}")
print(f"導師評語:{message}")
except ValueError:
print("\n錯誤:請輸入有效的數字!")
if __name__ == "__main__":
main()
📄 GitHub README (README.md)
Markdown# 📊 Score Checker (成績及格判斷器)
一個簡單、直觀且帶有防呆機制的 Python 程式,用於快速判斷學生成績是否及格,
並提供即時的回饋評語。
## ✨ 功能特色 (Features)
- **自動及格判定**:以 60 分為預設標準(可自行調整)。
- **輸入驗證與防呆**:
- 自動檢查分數是否在合法的 `0 ~ 100` 範圍內。
- 攔截非數字的字串輸入(如英文字母或符號),防止程式崩潰。
- **清晰易讀**:程式碼結構簡單,非常適合 Python 初學者參考與練習。
5.
age = int(input('Enter the age:'))
if not (age <15) and not(age>18):
print('You are Eligible to play in College Cricket:')
else:
print(' Sorry You cant play')
Output
#Case 1
Enter the age:24
Sorry You cant play
#case 2
Enter the age:16
You are Eligible to play in College Cricket:















留言
張貼留言