码迷,mamicode.com
首页 > 其他好文 > 详细

2.5计算小费.py

时间:2018-04-22 18:08:18      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:div   def   and   create   inpu   input   code   creat   rate   

# -*- coding: utf-8 -*-
"""
Created on Sun Apr 22 16:27:37 2018

@author: MyPC
"""

def main():
    ‘‘‘
    计算小费.
    
    公式:
    gratuity = subtotal * gratuity_rate
    total = gratuity + subtotal
    input:subtotal, gratuity_rate  
    output:gratuity, total
    ‘‘‘
    
    subtotal, gratuity_rate = eval(input("input subtotal, gratuity_rate:"))
    gratuity = subtotal * (gratuity_rate / 100)
    total = gratuity + subtotal
    print("The gratuity is %.2f and the total is %.2f :"%(gratuity, total))
    
    
if __name__ == "__main__":
    main()

 

2.5计算小费.py

标签:div   def   and   create   inpu   input   code   creat   rate   

原文地址:https://www.cnblogs.com/Wang-Y/p/8908302.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!