45.1k views
4 votes
What is the output of the following code snippet if the variable named cost contains 100? if cost < 70 or cost > 150 : discount = 0.8 * cost else : discount = cost print("Your cost is ", discount)

User Astoria
by
5.2k points

1 Answer

9 votes

Answer:

The output is: Your cost is 100

Step-by-step explanation:

Given

The above code snippet

and


cost = 100

Required

Determine the output of the code

if cost < 70 or cost > 150

The above condition checks if cost is less than 70 or cost is greater than 150

This condition is false because 100 is neither less than 70 nor is it greater than 150

So, the else statement will be executed.

discount = cost

Which means

discount = 100

So, the print instruction will print: Your cost is 100

User Keshava
by
5.5k points