Revising Programs Quick Check 3 of 53 of 5 Items Question Use the code to answer the question. def discount_on_voucher(voucher, amount): discount = 0 if voucher == 'Flat 50': discount = 0.5 * amount elif voucher == 'Flat 30': discount = 0.3 * amount elif voucher == 'Flat 20': discount = 0.2 * amount return discount disc = discount_on_voucher('Flat 75', 1000) print(f'Discount is {disc}') What will be the output of the code? Execute your code using the Trinket. Trinket (1 point) Responses The output will be “Discount is 150.” The output will be “Discount is 150.” The output will be “Discount is 200.” The output will be “Discount is 200.” The output will be “Discount is 0.” The output will be “Discount is 0.” The output will be “Discount of 1000.” The output will be “Discount of 1000.” Skip to navigation page 14 of 14

1 answer

To determine the output of the provided code, let's analyze it step by step:

  1. The function discount_on_voucher takes two parameters: voucher and amount.
  2. Inside the function, a variable discount is initialized to 0.
  3. Depending on the value of voucher, a different discount percentage is applied to amount:
    • If the voucher is 'Flat 50', it calculates a 50% discount (0.5 * amount).
    • If the voucher is 'Flat 30', it calculates a 30% discount (0.3 * amount).
    • If the voucher is 'Flat 20', it calculates a 20% discount (0.2 * amount).
  4. If the voucher does not match any of these, discount remains 0.
  5. The function returns the value of discount.

Now looking at the line:

disc = discount_on_voucher('Flat 75', 1000)

Since 'Flat 75' does not match any of the specified conditions ('Flat 50', 'Flat 30', 'Flat 20'), the discount variable retains its initial value of 0.

When we print out the result:

print(f'Discount is {disc}')

The output will be:

Discount is 0.

Therefore, the correct response is:

The output will be “Discount is 0.”

Similar Questions
    1. answers icon 2 answers
  1. Surface Area of Rectangular Prisms Quick Check3 of 53 of 5 Items Surface Area of Rectangular Prisms Quick Check 3 of 53 of 5
    1. answers icon 1 answer
  2. Family and Health Problems Quick CheckFamily and Health Problems Quick Check 1 of 31 of 3 Items Question Use the notes from your
    1. answers icon 0 answers
  3. Family and Health Problems Quick CheckFamily and Health Problems Quick Check 1 of 31 of 3 Items Question Use the notes from your
    1. answers icon 1 answer
more similar questions