Python 入門指南 5.0
exercise2203.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | # 從 exercise2201 引入 ParameterError
from exercise2201 import ParameterError
# 從 exercise2201 引入 higher
from exercise2202 import higher
# 執行部分
if __name__ == '__main__':
# 設定答案
answer = 100
# 取得使用者輸入
user_input = input("請輸入比較數字:")
# 印出比較結果
try:
print(higher(int(user_input), answer))
except ValueError:
print("型態轉換錯誤")
except ParameterError as p:
print(p)
# 檔名: exercise2203.py
# 說明:《Python入門指南》的練習
# 網站: http://kaiching.org
# 作者: 張凱慶
# 時間: 2023 年 10 月
|