Tracing a shipping decision in order

An online store uses the Python program below to work out what a customer owes. Orders of 50 dollars or more ship free; smaller orders pay a flat shipping charge.


Python
total = float(input("Order total: "))
if total >= 50:
    shipping = 0.00
else:
    shipping = 7.99
amount_due = total + shipping
print(amount_due)


A customer enters 42.50. Put the events of this run in the order the computer carries them out.

  1. 1.

    Compute amount_due as the sum of total and shipping.

  2. 2.

    Skip the assignment shipping = 0.00 in the if branch.

  3. 3.

    Assign 7.99 to shipping in the else branch.

  4. 4.

    Evaluate the condition total >= 50 and get False.

  5. 5.

    Print the value of amount_due.

  6. 6.

    Read the input and store 42.5 in total.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Decision Statements Questions: