Unit 3 Sections 1-2 Notes

Variables and Assignments Key Ideas (3.1)

  • Variables are abstractions within programs which represent a value
  • Values can be individual data points or a list/collection that contains many data values
  • Types of data can include numbers, Booleans (true or false), lists, and strings

Data Abstraction Key Ideas (3.2)

  • A list is made up of elements organized in a specific order
  • An element is a unique, individual value in a list
  • A string differs from a list as it is a sequence of characters rather than elements
  • Data abstraction uses a list by taking specific data elements from a list and organizing into a whole, less complex representation of the values such as a table

Python

  • To define a variable in Python, type in the variable name (one word) and use the = sign to set it equal to its value
  • Can be defined using numbers, string, list, or boolean
  • Strings must have quotations “” around it and lists must be surrounded by square brackets []
  • THe variable can now be used in functions such as print(‘’)
  • A dictionary can be created with keys and values in curly brackets {}
  • Variables can be interchanged with temporary variables (temp function)
  • They can also be defined with float data type which is used the same as integer

Homework and Challenge Problem

Click here for homework and challenge