3.3 Video 1 Hacks

Answers commented in code cells

numbers = [0,1,2,3,4,5,6,7,8,9,10]
evens = []

for i in numbers: # iteration
    if (numbers[i] % 2 == 0): # selection (if statement)
        evens.append(numbers[i])

print(evens)
i = 1
starString = "*"
while i <= 5: # iteration
  j = 1
  while j <= i: # selection, executing if specific condition is met
    print ("*", end= "") 
    j += 1
  print ()
  i += 1

# all of this makes a sequence

3.3 Video 2 Hacks

  1. a=1, b=7, c=3, d=7

  2. Hot and cold are swapped so hot becomes false and cold becomes true

Two of my own:

  1. a⟵5
  • b⟵10
  • c⟵30
  • d⟵20
  • e⟵15
  • e⟵a
  • d⟵e+b

ANSWER: a=5, b=10, c=30, d=15, e=5. a, b, and c all remain unchanged, while e gets reassigned to 5 and d becomes 5+10, which is 15.

  1. num1⟵5
  • num2⟵10
  • num3⟵30
  • num4⟵20
  • num5⟵15
  • num1⟵num5
  • num5⟵num2
  • num4⟵num5 + num1

ANSWER: num1=15, num2=10, num3=30, num4=25, num5=10. num1 gets reassigned to 15, while num2 and num3 remain unchanged. num5 becomes 10, while num4 becomes 10+15.

Sequencing question

num1=1+5=6, num2=6+5=11

3.4 Video 1 Hacks

Test 1: SmithB@gmail.com
Test 2: Ompuook (This one was kind of confusing so I looked at the answer)