Variables and Assigments

Variable: an abstraction inside a program that can hold a value

- can't use spaces in a variable
- Integer: number; usually for math
- String: text
- Boolean; true or false
- Storing variable:  Score ← 10

Data Abstraction

Strings

- An ordered sequence of character
- May contain letters, numbers and all other special characters
- Wors, phrases, sentences, ID numbers

Lists

- An ordered sequence of elements
- Each element is a variable

List index

- Each element of a string is referenced by an index
- Index start at 1 for AP exam
    - eg.animals: [“zebra”(1),”elephant”(2),...]

Data Abstraction -Lists

  • Lists allow for data abstraction
    • Bundle variables together
    • Strings, numbers, characters
      • Eg: colors ← [“red”,”blue”,”green”]

How lists manage complexity of a program

  • May no need as many variables
    • Variable for each students vs 1 variable = No need to add/delete entire variable
    • Consistent computations