Intro

  • Represent a value with a variable
  • Strings, lists, booleans, numbers
  • Determine the value of a variable as a result of an assignment

Defining in Pythin

  • To define a variable in python, just type in the variable name - one word - and use the = sign to set it equal to it's value.
  • variable can be defined using numbers, string, list, or boolean
  • Strings must have quotations around it
  • lists must be surrounded by square brackets

boolean: T or F

- define dictionary w curly brackets
    - create a new key and set it equal to a value
- can use floats ( a decimal)
    - can do division, multiplication, print them

Javascript

- var name = value;
- can use algebra
    - var x = x + y
- const also defines a variable

Boolean

- w = 6 and q = 5
- if w>6 boolean returns ture

Data Abstraction in Python

  • Manages complexity in a program and makes code easier to implement
  • differnt variables can hvae the same object
  • can split and join lists and the data inside them
numbervariable = 25
stringvariable = "i am so sleepy"
numberlist = [1, 2, 3, 4, 5]
listofstrings = ["red", "orange", "yellow", "green", "blue"]
israining = False

print(numbervariable)
print(stringvariable)
print(numberlist)
print(listofstrings)
print(israining)
25
i am so sleepy
[1, 2, 3, 4, 5]
['red', 'orange', 'yellow', 'green', 'blue']
False
number = 5  #defining the variable number
x = number * 2  #defining a variable by using another variable
print(number*2)  # multiplying a variable by 2
print(x)
10
10
list = []
list.append("flowers")
list.append("fruits")  # appending a value to a defined list
print(list)
['flowers', 'fruits']
mydictionary = {"dogies":"animals"}  # defining dictionary using curly brackets
mydictionary["banana"] = "fruit"   #add keys and values to a dict by setting a value equal to a key, like shown
mydictionary["couch"] = "furniture"  #editing a value inside the dictionary
print(mydictionary)
{'dogies': 'animals', 'banana': 'fruit', 'couch': 'furniture'}
// boolean in javascript
Boolean(w > q) //true
Boolean(w < q)  //false