Lesson Summary/What I learned

  • This lesson covered data sotorage utilizing variables. Data is categorized depending on the type of data it stores. Hence the term, data types. Numbers are stored in integers. Text is stored in strings. True and false are stored in booleans. Different data types have different use cases. FOr arithmetic, of course, integers must be used. For comparison and boolean arguements, of course, booleans must be used. For storing test or values besides numbers, a string must be used. Naming variables is sometimes a tedious task but it is crucial to maintain organization and cleansiness in code to name variables accordingly and precisely.

3.1 Homework/Hacks

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

    • apple_num, integer. able to be mutated by arithmetic
  • 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?

    • is_cold, boolean. it can either be cold or not (true/flase)
  • How do you store the ID numbers for the students in the classroom? Choose the best variable name and data type:

    • id_number, string. does not need to be mutated
  • Is itisRainingtodayinsandiego a better option than isRaining?

    • No, isRaining is more concise
  • Which of the following types of data is best for a true or false question?

    • Booleans store true or false
  • What is the difference between an integer and string of numbers?

    • Integer stores numbers and a string stores the numbers as text
  • My own scenarios

    • Storing a motor ID
      • motor_id, Integer
    • Storing grades in a class
      • grade, double
    • Storing if i have a good gpa
      • gpa, boolean

3.2 Homework/Hacks

  • Consider the following code segment: What are the contents of scores1 after the code segment is executed?:

     scores1 <- [89, 78, 92, 63, 95, 88]
     scores2 <- [92, 79, 97, 63]
     scores1 <- scores2
    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]
    • 4
  • 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"]
    • 1
  • What is the length of this list? ["Red", "Orange", "Yellow", "Green", "Blue", "Purple"]
    1. 5
    2. 7
    3. 6
    4. 4
      • 6
  • What is the index number of "Purple" in this list? ["Red", "Orange", "Yellow", "Green", "Blue", "Purple"]
    1. 7
    2. 0
    3. 6
    4. 5
      • 4
  • Which of the following types of data can be stored in a list?
    1. Boolean
    2. String
    3. Float
    4. All of the above
      • 4
  • Which of the following variables is a float?

    1. Apples
    2. -106.2
    3. 34
    4. True
      • 2
  • 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
      • 3
  • A variable is permanent and cannot be changed later on.

    1. True
    2. False
      • 2
  • 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
      • 6