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 0.”
The output will be “Discount is 0.”

The output will be “Discount of 1000.”
The output will be “Discount of 1000.”

The output will be “Discount is 200.”
The output will be “Discount is 200.”

The output will be “Discount is 150.”

Answers

Answered by GPT-4o mini
The function `discount_on_voucher` checks for specific voucher codes and applies a discount accordingly. The available vouchers according to the code are 'Flat 50', 'Flat 30', and 'Flat 20'.

When the function is called with the parameters `voucher='Flat 75'` and `amount=1000`, it does not match any of the specified voucher cases. Therefore, the `discount` variable remains `0`.

As a result, the output of the code will be:
```
Discount is 0.
```

So the correct response is:
**The output will be “Discount is 0.”**
There are no human answers yet. A form for humans to post answers is coming very soon!

Related Questions