Variables, Assignments, and Data Abstractions

An abstraction inside a program that can hold a value

Naming Variables

Tip: Make variables simple, easy to read, and relatively general for efficient code Ex: Do: highscore Don’t: highestscoreinthegame

Types of Data

  1. Integer: numbers
  2. Text: words
  3. Boolean: states if something is true or false

Assignments

allows a program to be change the value represented by a variable assigns values to varibales

Examples

Example 1 a=1 a=b a=2 print(b) b=1

  • will take the most recent value

Example 2 num1 = 5 num2 = 9 num1 = num2 print(num1) 9 print(num2) 9

Data Abstraction

represent data in a useful form; manages complexity

  • List and Indexes start at 1
  • Maximum number is the # of elements in the list
  • string = ordered sequencce of characters

3 Types of List operations

  1. Assigning values to a list of certain indicies
  2. Creating an empty list and assigning it values
  3. Assigning a copy of a list