のりよし関数 [のりよし Advent Calendar 2017](https://adventar.org/calendars/2192)の2日目の記事です。 ```python WEEKS_PER_YEAR = 52 # のりよしがこれまでにGBに使った金額(円)を計算する def noriyoshi( # 平均支払い金額(円) payment, # 一週間あたりの平均GB回数 gbs_per_week, # GBに行きはじめてからの年数 years): """Return total payment of GB >>> noriyoshi(payment=1000, gbs_per_week=2, years=3) 312000 >>> noriyoshi(payment=500, gbs_per_week=2, years=3) Traceback (most recent call last): ... ValueError: noriyoshi must pay more than 1000 yen for GB >>> noriyoshi(payment=1000, gbs_per_week=0, years=3) Traceback (most recent call last): ... ValueError: noriyoshi must go to 1 GB per week >>> noriyoshi(payment=1000, gbs_per_week=2, years=1) Traceback (most recent call last): ... ValueError: niriyoshi must have GB experience over 3 years """ if payment < 1000: raise ValueError("noriyoshi must pay more than 1000 yen for GB") if gbs_per_week < 1: raise ValueError("noriyoshi must go to 1 GB per week") if years < 3: raise ValueError("niriyoshi must have GB experience over 3 years") return payment * gbs_per_week * years * WEEKS_PER_YEAR if __name__ == '__main__': import doctest doctest.testmod() ``` ```bash $ python3 Python 3.6.0 (default, Feb 16 2017, 02:21:07) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import noriyoshi >>> noriyoshi.noriyoshi(payment=3000, gbs_per_week=2, years=5) 1560000 >>> ``` のりよしがこれまでにGBに使った金額は、推定_156万円_です 明日は[やすさん](https://twitter.com/yatmsu)の、のりよしです。