
開啟 Anaconda 命令面板(或是 conda),輸入以下指令安裝 pytest
pip install pytest
之後下指令,使用你要檢查的 .py 檔案
pytest Homework.py
def calc_tax(e): sta_mainasu = e - 88000 - 90000 - 128000 if e > 0 and e <= 540000: return sta_mainasu * 0.05 elif e > 540000 and e <= 1210000: return sta_mainasu * 0.12 - 37800 elif e > 1210000 and e <= 2420000: return sta_mainasu * 0.2 - 134600 elif e > 2420000 and e <= 4530000: return sta_mainasu * 0.3 - 376600 elif e > 4530000 and e <= 10310000: return sta_mainasu * 0.4 - 829600 elif e > 10310000: return sta_mainasu * 0.45 - 829600 def test_ansA(): assert calc_tax(540000) == 11700 def test_ansB(): assert calc_tax(630000) == 1080 def test_ansC(): assert calc_tax(1220000) == 48200 def test_ansD(): assert calc_tax(2440000) == 263600 def test_ansE(): assert calc_tax(5630000) == 1300000 def test_ansF(): assert calc_tax(20000000) == 8032700
def Room_Select(people): if people > 15: return 1260 elif people > 12: return 910 elif people > 9: return 770 elif people > 6: return 630 elif people > 3: return 490 elif people > 1: return 350 else: return 0 def KTV_Select(People_Count, People_Method): Method_People = ((350 + 138) * People_Count) * 1.1 Method_Room = (Room_Select(People_Count) * 3 + People_Count * 138) * 1.1 if People_Method == 1: return (round(Method_People)) else: return (round(Method_Room)) def test_1(): assert KTV_Select(2, 1) == 1074 def test_2(): assert KTV_Select(3, 1) == 1610 def test_3(): assert KTV_Select(4, 1) == 2147 def test_4(): assert KTV_Select(5, 2) == 2376 def test_5(): assert KTV_Select(8, 2) == 3293 def test_6(): assert KTV_Select(12, 2) == 4363 def test_7(): assert KTV_Select(15, 2) == 5280 def test_8(): assert KTV_Select(20, 2) == 7194
Latest posts by SHXJ (see all)
- 受保護的內容: NAS 版 Mathbot 管理網站與 Linebot 啟動方法 - 2024 年 11 月 15 日
- Realtime 啥鬼的 - 2021 年 6 月 15 日
- nodejs 數學遊戲 - 2021 年 6 月 8 日