Python practice: Boolean Truth Testing & Comparisons

Chapter 5 · 8 questions · included in full access

  1. Question 1 · easy

    Check sales target threshold

    Given sales = 85 and target = 80, check if sales >= target and print the boolean result:

    Solve it in your browser
  2. Question 2 · easy

    Equality vs assignment check

    Given region = "North", print whether region == "North" on line 1, and region == "South" on line 2:

    Solve it in your browser
  3. Question 3 · easy

    Logical and operator

    Given units = 25 and tier = "Gold", check if units >= 20 and tier == "Gold". Print the boolean result:

    Solve it in your browser
  4. Question 4 · easy

    Logical or operator

    Given is_weekend = False and is_holiday = True, check if is_weekend or is_holiday and print whether the office is closed:

    Solve it in your browser
  5. Question 5 · easy

    Membership testing with in

    Given approved = ["North", "South", "West"] and user_region = "North", print whether user_region in approved:

    Solve it in your browser
  6. Question 6 · easy

    Negative membership with not in

    Given banned_skus = ["SKU-99", "SKU-00"] and item = "SKU-42", verify item not in banned_skus and print the result:

    Solve it in your browser
  7. Question 7 · easy

    Truthiness of empty strings and zero

    Print bool("") on line 1 and bool(0) on line 2 to demonstrate falsy values in Python:

    Solve it in your browser
  8. Question 8 · medium

    Budget threshold verification

    Given spent = 14500 and budget = 15000, print True if spent <= budget, otherwise False:

    Solve it in your browser

These questions are part of full access.

The first chapters of every track are free. Full access is a one-time payment.

See pricing