Count the tests that actually run

A dispatch program runs the following Python code once for each parcel. The variable mass gives the parcel mass in kilograms; express and fragile contain Boolean values.


Python
if mass <= 20:
    if express:
        if fragile:
            print("Padded express")
        else:
            print("Express")
    else:
        print("Standard")
else:
    print("Oversize")


Count a condition evaluation whenever execution reaches an if and tests its condition. An else does not perform another test.


Parcel

Mass (kg)

express

fragile

Birch

24

True

True

Cedar

12

False

True

Maple

8

True

False

Pine

20

True

True


Across these four independent runs, find the total number of condition evaluations and the number of those evaluations that return true. Enter both counts as exact integers.

Your answers

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 Nested Decisions Questions: