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

2015-10-18 0 871
北京地铁月支出简易计算器
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import division
import math

#  0-100 *1
#  100< <=150 *0.8
#  150<       *0.5
def 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 total

if __name__ == '__main__':
    print("单次票价, 月支出,  年支出")
    for i in range(3,9):
        perMonth =caclMonthFee(i)
        print(i, perMonth, round(perMonth*12,1))

遇见资源网 python 北京地铁月支出简易计算器 http://www.ox520.com/15849.html

上一篇: 分形图
下一篇: 基本字符串压缩
常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务