Vocab

Boolean: binary variable with only two possible values, "true" or "false"

Algorithm: Finite set of instructions that accomplish a specific task

Nested conditional: A conditional inside of a conditional

3.5 Hacks

Binary Practice

Question Answer
1. false
2. false
3. true
4. false
AND Operator
Value 1 Value 2 Result
1 1 1
1 0 0
0 1 0
0 0 0
OR Operator
Value 1 Value 2 Result
1 1 1
1 0 1
0 1 1
0 0 0
Not operator
Not Value Result
Not 1 0
Not 0 1

python practice

print(20 == 10) # prints value false

x = 30
y = 20
z = 10
print(x > y - z) # changed addition to subtraction

# Manipulate the variables x, y, and z to make the below statement return true
print(x == z + y)

3.6 Hacks

AP Prep

Question Answer
1. 3
2. 2
3. 2
4. 1

using python

animals = ["lion", "tiger", "wildebeest", "shark", "jellyfish", "blobfish", "raven"]

for i in animals:
    if i == "wildebeest" or "lion": # What boolean value does this statement cause? true
        print("This animal lives in the desert")
    else:
        print(i)

# Practice
# Using only one more if statement, alter the code to print out a statement saying if an animal lives in the desert, based on booleans
This animal lives in the desert
This animal lives in the desert
This animal lives in the desert
This animal lives in the desert
This animal lives in the desert
This animal lives in the desert
This animal lives in the desert

3.7 Hacks

Exercise 1

Meals = {"Chicken Alfredo": ["Chicken",  60],
        "Cheese Quesadilla": ["None",  10],
        "Beef Wellington": ["Beef",  150]
        }

for meal in Meals.values():
    if meal[0] == "None" and meal[1] <= 30:
        print("cook this meal")
cook this meal