Hacks for 3.1 Part 1

You want to store the number of apples in a shop. What is the best variable name and data type?

  1. numApples, integer
  2. apples, text
  3. numApples, string
  4. isApples, boolean

You are storing true or false in a variable that asks if the classroom is cold. What is the best variable name and data type?

  1. weather, integer
  2. weather, boolean
  3. isCold, boolean
  4. cold, string

How do you store the ID numbers for the students in the classroom? Choose the best variable name and data type:

  1. IDnumber, string
  2. whatID, integer
  3. IDnumberofthestudentsintheclassroom, boolean
  4. IDnumberofthestudentsintheclassroom, integer

Is itisRainingtodayinsandiego a better option than isRaining?

  1. Yes
  2. No

Which of the following types of data is best for a true or false question?

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

What is the difference between an integer and string of numbers?

  1. An integer is just a set data type while a string of numbers can be changed with addition and subtraction
  2. An integer can be letters and numbers while a string is just numbers
  3. An integer is just numbers while a string is just words
  4. An integer can be changed with addition and subtraction and a string is a set number or string of letters.

Now, make at least 3 of your own practice questions making a scenario and then adding the variable name and data type. Add this to you blog!

You are storing player numbers. Choose the best variable name and data type:

Answer: Playernum, string

You are deciding if it is raining. Choose the best variable name and data type:

Answer: isRaining, boolean

You want to track how much money is in your bank account. Choose the best variable name and data type:

Answer: numMoney, integer

Hacks for 3.1 Part 2

Answer the practice problems and blog about which one's you got wrong. After, create at least 6 problems that are alike to what you learned in this portion of the lesson.


Consider the following code segment:

  • currentScore ⟵ 10
  • highScore ⟵ currentscore
  • currentScore ⟵ 7

DISPLAY (currentScore)

What will the currentScore be after running this code segment?

  1. 17
  2. 10
  3. 7
  4. none of the above

What will the highScore be?

  1. 17
  2. 10
  3. 7
  4. none of the above

Consider the following code segment:

  • num1 ⟵ 4
  • num2 ⟵ 6
  • num1 ⟵ num 2

DISPLAY(num1)

DISPLAY(num2)

What is displayed after running this code segment?

  1. 4 6
  2. 6 4
  3. 4 4
  4. 6 6

Consider the following code segment:

  • num1 ⟵ 25
  • num2 ⟵ 15
  • num3 ⟵ 30
  • num2 ⟵ num3
  • num3 ⟵ num1
  • num1 ⟵ num2

DISPLAY(num1)

DISPLAY(num2)

DISPLAY(num3)

What is displayed after running this code segment?

  1. 25 15 30
  2. 30 30 25
  3. 30 15 30
  4. 15 30 25

Consider the following code segment:

  • p ⟵ 10
  • q ⟵ 20
  • r ⟵ 30
  • s ⟵ 40
  • p ⟵ q
  • q ⟵ r
  • s ⟵ q
  • r ⟵ p

What is the value of r as a result of running this code segment

  1. 10
  2. 20
  3. 30
  4. 40

Consider the following code segment:

  • first ⟵ true
  • second ⟵ false
  • second ⟵ first
  • first ⟵ second

Insert Question

  1. The value of first is true, and the value of second is false.
  2. The value of first is false, and the value of second is true.
  3. The value of first is true, and the value of second is true.
  4. The value of first is false, and the value of second is false.

Consider the following code segment:

  • a ⟵ 10
  • b ⟵ 20
  • c ⟵ 30
  • d ⟵ 40
  • x ⟵ 20
  • b ⟵ x + b
  • a ⟵ x + 1
  • d ⟵ c / d + 2

DISPLAY(a)

DISPLAY(b)

DISPLAY(c)

DISPLAY(d)

What is displayed as a result of executing the code segment?

  1. 21 40 30 50
  2. 10 20 30 40
  3. 21 40 30 40
  4. 21 30 40 50

Binary Hacks 3.2 Part 1

Convert these binary notation to decimal notation. (the way we normally count)

  1. The binary number 111 is 7

  1. The binary number 1011 is 11

  1. The binary number 1101011 is 107

Convert the decimal notation to binary notation. (You can use the Binary Math from Mr. Yeung or the one you have)

  1. 12 in binary is 1100

  1. 44 in binary is 101100

  1. 254 in binary is 11111110

Extra Binary Hacks if you changed your bits to 24

Convert decimal notation to binary notation.

  1. 57345 in binary is 1110000000000001

  1. 16777215 in binary is 111111111111111111111111

  1. 11184810 in binary is 101010101010101010101010

Convert the binary notation to decimal notation

  1. 101011101010 in decimal notation is 2794

  1. 10011100000 in decimal notation is 1248

  1. 1101001000101000 in decimal notation is 53800

Hacks for 3.2 Part 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]

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"]

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

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

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

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

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

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

Which of the following variables is a float?

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

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

A variable is permanent and cannot be changed later on.

  1. True
  2. False

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

What I Learned

  • How to replace lists
  • Converting binary
  • Learned more about lists, boolean, variables, and integers
  • Most of this I already knew, but this taught me to read the code better and understand it deeper