 1 # ケース２修正版
 2 
 3 from datetime import datetime, date
 4 
 5 def case2_mod(cust, cash):
 6     print('=== Start case2 MOD ===')
 7 
 8     # 辞書で日付毎のポイントを定義
 9     point_def = {1:5,
10               5:3,15:3,25:3,
11               10:1,20:1,30:1}
12     # 会員の場合の追加ポイントを定義     ←定義をまとめた
13     point_cust = {5:1,15:1,25:1,
14                   10:1,20:1,30:1}
15     # 現金会員の場合の追加ポイントを定義
16     point_cash = {10:1,20:1,30:1}
17 
18     
19     # 日付を取得
20     dt = date.today()
21 
22     # 基本ポイントの設定
23     point = point_def.get(dt.day, 0)
24 
25     # 会員の場合のポイント追加
26     if cust:
27         point += point_cust.get(dt.day, 0)
28         # 現金会員の場合のポイント追加
29         if cash:
30             point += point_cash.get(dt.day, 0)
31 
32     # 現金会員はいつでも最低1%
33     if point == 0 and cust == True and cash == True:
34         point = 1
35 
36     print('会員：' + str(cust) + '、現金：' + str(cash) + '、ポイント='+str(point))
37     print('=== Finish case2 MOD ===')
38 
39 
40 # メイン
41 if __name__ == "__main__":
42     case2_mod(True, True)
43     case2_mod(True, False)
44     case2_mod(False, False)
