3.1 Video 2

Question 1

  1. because that is the latest value that was stored within the variable.

Question 2

  1. because the value stored in a variable will alwasy be the most recent value assigned.

Question 3

  1. because the value for num 2 becomes the value of num 1 therefore making the first outcome 6 and the second outcome would be six as well because that is the value that num2 is assigned.

Question 4

  1. because for num 1 the value is replaced by num 3’s value which is 30. For num 2 the value is 30 because its replaced by num 1’s value which was originally 25 but then was replaced by num 3’s value 30. For num 3, the value is 25 because it’s value is replaced by num 2 which num 2’s value was replaced by num 1’s.

Question 5

  1. because q is the variable assigned to p and q’s value is 20.

Question 6

  1. because the first two statements assign values to the variables. The third statement assigns the value of first (which is true) to second. The fourth statement assigns the value of second (which is true) to first.

Question 7

  1. because the first five statements assign values to the variables. The sixth statement assigns the value of x + b (which is 40) to b. The seventh statement assigns the value of x + 1 (which is 21) to a. The eighth statement assigns the value of c + d / 2 to d. According to the order of operations, division has higher precedence than addition. Since c is 30 and d / 2 is 20, d is assigned the value 50. The last four statements display the values of a, b, c, and d.

3.1 Video 1

Practice questions that I made

  1. Consider the following code segment:

num1 ⟵ 12 num2 ⟵ 3 num3 ⟵ 9 IF num1 < num2

num1 ⟵ num2 ELSE

num3 ⟵ num2 IF num2 ≥ num3

num1 ⟵ num2 + num3 sum ⟵ num1 + num2 + num3

What is the value of sum after the code segment is executed?

a. 18

b. 17

c. 1

d. 19

answer:17

  1. Consider the following code segment:

num1 ⟵ 7 num2 ⟵ 2 num3 ⟵ 19 IF num1 < num2

num1 ⟵ num2 ELSE

num3 ⟵ num2 IF num2 ≥ num3

num1 ⟵ num2 + num3 sum ⟵ num1 + num2 + num3

What is the value of sum after the code segment is executed?

a. 22

b. 28

c. 12

d. 16

answer: 16

  1. Consider the following code segment:

num1 ⟵ 9 num2 ⟵ 4 num3 ⟵ 3 IF num1 < num2

num1 ⟵ num2 ELSE

num3 ⟵ num2 IF num2 ≥ num3

num1 ⟵ num2 + num3 sum ⟵ num1 + num2 + num3

What is the value of sum after the code segment is executed?

a. 11

b. 15

c. 17

d. 12

answer: 12

  1. Consider the following code segment:

num1 ⟵ 7 num2 ⟵ 12 num3 ⟵ 10 IF num1 < num2

num1 ⟵ num2 ELSE

num3 ⟵ num2 IF num2 ≥ num3

num1 ⟵ num2 + num3 sum ⟵ num1 + num2 + num3

What is the value of sum after the code segment is executed?

a.17

b. 3

c. 16

d. 5

answer: 16

  1. Consider the following code segment:

num1 ⟵ 6 num2 ⟵ 4 num3 ⟵ 10 IF num1 < num2

num1 ⟵ num2 ELSE

num3 ⟵ num2 IF num2 ≥ num3

num1 ⟵ num2 + num3 sum ⟵ num1 + num2 + num3

What is the value of sum after the code segment is executed?

a. 2

b. 16

c. 12

d. 4

answer:4

  1. Consider the following code segment:

num1 ⟵ 6 num2 ⟵ 4 num3 ⟵ 10 IF num1 < num2

num1 ⟵ num2 ELSE

num3 ⟵ num2 IF num2 ≥ num3

num1 ⟵ num2 + num3 sum ⟵ num1 + num2 + num3

What is the value of sum after the code segment is executed?

a. 13

b. 14

c. 19

d. 11

answer:11

Question 1

1. Because the name is descriptive of what is stored. Also, the number of apples in the store can change so the integer lets you add a nd subtract to the number of apples. ## Question 2 
  1. Because this is a true or false question. It is either cold or not, so the variable name describes the circumstance, then the boolean data type specifies true or false.

Question 3

  1. IDnumber because it is descriptive but not too long and innefective. it is also a string because it doesn’t change and its a string of numbers.

Question 4

  1. No, because it is too long and inefficient to use when trying to store variables.

Question 5

  1. A boolean data type allows a variable to store true and false.

Question 6

  1. This is the only answer that has two true statements

My Three questions:

To check if it is in the afternoon or not what would the answer be? Is it afternoonYes and boolean?

To check if the tide is good for surfing, what would the answer be? Is it tideGood and String?

To record the color of a shoe, what would the answer be? Is it shoeColor and string?

Binary Hacks

  1. 7
  2. 11
  3. 107
  4. 1100
  5. 101100
  6. 11111110

    3.2 Video 2

Question 1

4. Because the data is not being appended from scores2 into scores1. 

Question 2

  1. Because all of the data from listA “Sam” and “Ann” replace what is in listB. So if listB replaces what is in listA, “Sam” and “Ann” will still be the only data in that list.

Question 3

  1. The length of the list is 6.

Question 4

  1. The index count starts at 0, making “Red” 0 and “Purple” index 5.

Question 5

  1. Any type of data can be stored within a list. A list can contain a mix of types of data.

Question 6

2. A float is a decimal number.

Question 7

  1. An index count starts at 0 so the index number of a variable is one less than it’s spot in the length.

Question 8

  1. False. Variables can be changed later on in the code.

Question 9

  1. The list has floats or decimals and strings, and the length is 10, the ratio of string to floats is 1:1, and the index number of “Avocado” is 4.