python A credit card company computes a customer's "minimum payment" according to the following rule. The minimum payment is equal to either $10 or 2.1% of the customer's balance, whichever is greater; but if this exceeds the balance, then the minimum payment is the balance. Write a program to print out the minimum payment using min and max. Assume that the variable balance contains the customer's balance. Your program does not need to print the dollar sign. Example 1: if your balance is 1000, then your program should print 21.

Respuesta :

Answer:

# user is prompt to enter balance

balance = int(input("Enter your balance: "))

# 21% of the balance is calculated

balancePercent = 0.021 * balance

# The greater of $10 and balance persent is assigned to minimumPayment using max()

minimumPayment = max(10, balancePercent)

# the least between minimumPayment and the balance is assigned to minimumPayment using min()

minimumPayment = min(minimumPayment, balance)

# minimumPayment is displayed to user

print(minimumPayment)    

Explanation:

The program is written in Python3 and well commented. First the user is prompt to enter the balance. Then 21% of the balance is computed and assigned to balancePercent. Then using max( ) we find the maximum between 10 and the balancePercent which is assigned to minimumPayment.

The we use min( ) to find the minimum between the existing minimumPayment and the balance and assigned to minimumPayment.

The minimumPayment is then displayed to user.

max( ) and min( ) are inbuilt function of python that is use to get the maximum and minimum of the passed arguments.