3.1 Video 2:

I did not get any questions wrong, but some of them took me longer than others, especially since I was doing it all in my head. It is hard to keep track of variables, so maybe actually writing down what the variables change to might make it easier. I did learn that it is important to keep track of variables being rearranged and reassigned to make sure that code is working as intended.

My questions:

num1⟵3
num2⟵5
num3⟵10
num1⟵num2
num3⟵num1

DISPLAY(num1)
DISPLAY(num2)
DISPLAY(num3)

ANSWER: 5 5 5

a⟵5
b⟵10
c⟵15
d⟵20
a⟵d
d⟵a
c⟵b

DISPLAY(a)
DISPLAY(b)
DISPLAY(c)
DISPLAY(d)

ANSWER: 20 10 10 20

x⟵1
y⟵2
z⟵3
x⟵y
y⟵z
z⟵x

DISPLAY(x)
DISPLAY(y)
DISPLAY(z)

ANSWER: 2 3 2

a⟵10
b⟵20
c⟵40
c⟵a
b⟵c

DISPLAY(a)
DISPLAY(b)
DISPLAY(c)

ANSWER: 10 10 10

num1⟵30
num2⟵40
num3⟵50
num4⟵20
num1⟵num2
num3⟵num4

DISPLAY(num1)
DISPLAY(num2)
DISPLAY(num3)
DISPLAY(num4)

ANSWER: 40 40 20 20

a⟵2
b⟵4
c⟵6
d⟵8
a⟵d
b⟵a
c⟵b

DISPLAY(a)
DISPLAY(b)
DISPLAY(c)
DISPLAY(d)

ANSWER: 8 8 8 8

3.1 Assignment 1

  1. numApples and integer is the best, since it is a numerical value
  2. isCold is the best variable, and boolean is the best as it is true or false
  3. IDnumber and string is the best. Even though it is a number you are not adding or subtracting from it
  4. No, isRaining is better, the other one is way too long.
  5. Boolean is best for true or false
  6. Integer is to be added or subtracted to. String is for objects or numbers you are not going to be adding or subtracting to.

My own questions

What would be the best variable for storing first names?

  1. firstName
  2. firstname
  3. first name
  4. peoplesfirstnames

ANSWER: 1. firstName

What type of data would you use to store zip codes?

  1. Integer
  2. String
  3. Boolean

ANSWER: 2. String

What type of data would you use to keep track of the number of oranges?

  1. Integer
  2. String
  3. Boolean

ANSWER: 1. Integer

3.2 Video 2

Consider the following code segment:

  • scores1 <- [89, 78, 92, 63, 95, 88]
  • scores2 <- [92, 79, 97, 63]
  • scores1 <- scores2 What are the contents of scores1 after the code segment is executed?:
  1. [89, 78, 92, 63, 95, 88]
  2. [89, 78, 92, 63, 95, 88, 92, 79, 97, 63]
  3. [92, 79, 97, 63, 89, 78, 92, 63, 95, 88]
  4. [92, 79, 97, 63]

MY ANSWER: 4. [92, 79, 97, 63] (correct)

Consider the following code segment:

  • listA <- [“Sam”, “Ann”]
  • listB <- [“Jamal”, “Tamara”]
  • listB <- listA
  • listA <- listB What are the contents of listA after the code segment is executed?
  1. [“Sam”, “Ann”]
  2. [“Jamal”, “Tamara”]
  3. [“Sam”, “Ann”, “Jamal”, “Tamara”]
  4. [“Jamal”, “Tamara”, “Sam”, “Ann”]

MY ANSWER: 1. [“Sam”, “Ann”] (correct)

What is the length of this list? [“Red”, “Orange”, “Yellow”, “Green”, “Blue”, “Purple”]

  1. 5
  2. 7
  3. 6
  4. 4

MY ANSWER: 1. 5 (incorrect, I was thinking of the index numbers)

What is the index number of “Purple” in this list? [“Red”, “Orange”, “Yellow”, “Green”, “Blue”, “Purple”]

  1. 7
  2. 0
  3. 6
  4. 5

MY ANSWER: 4. 5 (correct)

Which of the following types of data can be stored in a list?

  1. Boolean
  2. String
  3. Float
  4. All of the above

MY ANSWER: 4. All of the above (correct)

Which of the following variables is a float?

  1. Apples
  2. -106.2
  3. 34
  4. True

MY ANSWER: 2. -106.2 (correct)

If a list has a length of 24 items, what is the index number of the 17th item?

  1. 21
  2. 17
  3. 16
  4. 69

MY ANSWER: 3. 16 (correct)

A variable is permanent and cannot be changed later on.

  1. True
  2. False

MY ANSWER: 2. False (correct)

Which of the following is true about the list? [“Apples”, 42.0, “Bananas”, 0.5, “Avocado”, -902.2, “Lychee”, 6.9, “Orange”, 7.2]

  1. The list has floats and string variable types.
  2. The ratio of float variables to string variables is 2:1.
  3. The length is 9.
  4. The index of “Avocado” is 4.
  5. All of the above
  6. 1 and 4
  7. 1, 3, and 4

MY ANSWER: 6. 1 and 4