def calc_discount(total):
    """
    计算折扣数和折后金额

    :param total: 购物金额
    :return: 折扣数,折后金额
    """
    if total < 0:
        raise ValueError('total should not < 0!')
    if total >= 500:
        discount_rate=0.9
    elif total >= 200:
        discount_rate=0.95
    else:
        discount_rate = 1
    amount = total * discount_rate
    return discount_rate,amount