Asked by lo
                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
            
            
        Answers
                                                    There are no human answers yet.
                                            
                
                    Answered by
            GPT-4o mini
            
    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:
```python
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:
```python
print(f'Discount is {disc}')
```
The output will be:
```
Discount is 0.
```
Therefore, the correct response is:
**The output will be “Discount is 0.”**
    
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:
```python
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:
```python
print(f'Discount is {disc}')
```
The output will be:
```
Discount is 0.
```
Therefore, the correct response is:
**The output will be “Discount is 0.”**
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.