Chapter 3.3 and 3.4

Video 2 Hacks a ⟵ 7

b ⟵ 1

c ⟵ 3

d ⟵ 4

a ⟵ b

b ⟵ c + d

d ⟵ b

Answer:a = 1, b = 7, c = 3, d = 7

hot ⟵ true

cold ⟵ false

cold ⟵ hot

hot ⟵ cold

Asnwer: Hot = true and Cold = true

dog ⟵ yes

cat ⟵ no

cat ⟵ dog

cow ⟵ pig

pig ⟵ owl

display(cat)

Asnwer: Displays yes since dog = yes, then cat = dog which = yes, everything after that does not matter because we are displaying cat cookie ⟵ 3

cake ⟵ 2

cookie ⟵ cake

donut ⟵ 5

chocolate ⟵ donut

caramel ⟵ 3

display(donut + cake + cookie + chocolate + caramel)

Answer: 17 because 5 + 2 + 2 + 5 + 3

Test 1

firstName <- “Bob” lastName <- “Smith” var <- substring(firstName, 1, 1) name <- concat(lastName, var) email <- concat(name, “@gmail.com”) DISPLAY(email)

What would the result be?

Hint: var = “B” name = “SmithB”

Asnwer: “SmithB@gmail.com”

Test 2 word1 <- “computer” word2 <- “textbooks” length1 <- len(word1)/2 length2 <- len(word2)/3 first <- substring(word1, 2, len1) second <- substring(word2, len2+3, len2) newWord <- concat(first, second) DISPLAY(newWord)

Answer: 8/2 = 4 – ompu, 9/3 = 3 – ook, ompu + ook = ompuook