python北京地铁月支出简易计算器,python北京地铁支出,python北京地铁月支


python北京地铁月支出简易计算器
BeiJing地铁月支出简易计算器,每月按22天计算,每天上下班两次.
单次票价,月支出,年支出
(3,126.0,1512.0)
(4,157.2,1886.4)
(5,179.5,2154.0)
(6,202.8,2433.6)
(7,225.4,2704.8)
(8,247.2,2966.4)

python北京地铁月支出简易计算器代码片段

1.[代码]Beijingsubway fee

#!/usr/bin/env python# -*- coding: utf-8 -*-from __future__ import divisionimport math#  0-100 *1#  100< <=150 *0.8#  150<       *0.5def caclMonthFee(perPrice):    totalTimes=22*2    firstTimes = math.ceil(100/perPrice)    secondTimes = math.ceil(50/(perPrice*0.8))    if (firstTimes + secondTimes > totalTimes):        secondTimes = (totalTimes -firstTimes)        thirdTimes=0    else:        thirdTimes = totalTimes-int(firstTimes)-int(secondTimes)    total=firstTimes*perPrice+secondTimes*perPrice*0.8+thirdTimes*perPrice*0.5    return totalif __name__ == '__main__':    print("单次票价, 月支出,  年支出")    for i in range(3,9):        perMonth =caclMonthFee(i)        print(i, perMonth, round(perMonth*12,1))

编橙之家文章,

评论关闭