2.5计算小费.py

# -*- 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()
原文地址:https://www.cnblogs.com/Wang-Y/p/8908302.html