Use the code to answer the question.

if age > 40:
# 15 percent discount
discount = discount + (0.15 * amount)
if category == 'A':
# 10 percent discount
discount = discount + (0.1 * amount)
Revise the code to incorporate the given policies:

If the client is older than 40 and he buys from category “C,” he gets a discount of 55 percent.
All discount policies for category “A” are revoked.
(1 point)
Responses

if age > 40:
# 15 percent discount
discount = discount + (0.15 * amount)
if category == 'A':
# 55 percent discount
discount = discount + (0.55 * amount)
if age > 40: # 15 percent discount discount = discount + (0.15 * amount) if category == 'A': # 55 percent discount discount = discount + (0.55 * amount)

if age > 40:
# 15 percent discount
discount = discount + (0.15 * amount)
if category == 'C':
# 55 percent discount
discount = discount + (5.55 * amount)
if age > 40: # 15 percent discount discount = discount + (0.15 * amount) if category == 'C': # 55 percent discount discount = discount + (5.55 * amount)

if age > 40:
# 15 percent discount
discount = discount + (0.15 * amount)
if category == 'C':
# 55 percent discount
discount = discount + (0.55 * amount)
if age > 40: # 15 percent discount discount = discount + (0.15 * amount) if category == 'C': # 55 percent discount discount = discount + (0.55 * amount)

if age > 40:
# 15 percent discount
discount = discount + (0.15 * amount)
if category == C:
# 55 percent discount
discount = discount + (0.55 * amount)

1 answer

To correctly revise the code based on the specified policies, we need to incorporate the following rules:

  1. If the client is older than 40, they receive a 15 percent discount.
  2. If the client buys from category "C," they receive a discount of 55 percent.
  3. All discounts for category "A" should be revoked (therefore, there should be no additional discounts for category "A").

Here is the correct revision of the code:

if age > 40:
    # 15 percent discount
    discount = discount + (0.15 * amount)

    if category == 'C':
        # 55 percent discount
        discount = discount + (0.55 * amount)

With this code, the client receives a 15 percent discount if they are older than 40 and an additional 55 percent discount if they belong to category "C." Any discounts for category "A" are revoked, meaning there would be no additional computations for it.

Here’s the breakdown of the possible responses:

  • The option that correctly implements the specified discount policies is:
if age > 40:
    # 15 percent discount
    discount = discount + (0.15 * amount)
    if category == 'C':
        # 55 percent discount
        discount = discount + (0.55 * amount)

This statement correctly applies a 15 percent discount as well as a 55 percent discount only for category "C."