To determine the output of the provided code, let's analyze it step by step:
- The function
discount_on_voucher
takes two parameters:voucher
andamount
. - Inside the function, a variable
discount
is initialized to 0. - Depending on the value of
voucher
, a different discount percentage is applied toamount
:- 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).
- If the voucher does not match any of these,
discount
remains 0. - 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.”