Variables

  • Abstraction inside a program that can hold a value
  • Organizes data by giving it a descriptive name
  • Varible contains 3 parts: Name, Value, and Type
  • Keep it simple, don’t make it long to make your code messy. Make it specific enough that anyone could understand.

Do’s and Don’ts

-Don’t have spaces, letters that are two broad

Types of Data

  • Integer: A number -Text/String: A word -Boolean: Data that determines something is true or false

Assignments

  • Operators assign a value to a variable in a different way.

-Example:

a=1 b=2 a=b Then a would be 2 instead of 1

Data Abstraction

-Used to represent data in a useful form that gets rid of the un-needed elements

-Variables and lists are primary tools in data abstraction

-Provides a separation between the abstract properties of a data type and the concrete details of its representation

Lists and strings

  • List = ordered sequence of elements Element = individual value in a list that is assigned to a unique index

-Index = a way to reference the elements in a list or string using natural numbers; each element of a string is referenced by an index

-String = ordered sequence of characters (Letters, numbers, special characters)

  • 3 types of list operations

How does Data Abstraction Improve managing Complexity?

  • Improve code reability

  • Reduce un-needed variables

  • Update Data Easier

  • Convert Data into a different form that you want easier

Mathmatical Expressions and Strings

Algorithm

  • Algorithms have steps, flow charts can help vizualize these steps

Order of Operations

Arithmetic operations in programming are performed in the same order as operations in mathematics:

Operations in parentheses should be done first.

Division and multiplication should be done before addition and subtraction.

Modulus works similar to multiplication and division.

Variables

  • Important to keep track of the variables because they can constantly change overtime with code

Strings

What is a string?

A String: A string is a collection of characters. What is a character as character can be anything from numbers, letters, spaces, special symbols, etc.

A string is a collection of characters. What is a character as character can be anything from numbers, letters, spaces, special symbols, etc.

Here are some hacks:

-len() to find the length of a string

-lower() to convert to lowercase

-etc. Pseudocode examples

-len() returns the length of a string

-concat() returns a string made up of the concatenated strings ex. concat(“string1”, “string2”) would return string1string2

substring() returns the characters from the string beginning at the at the first position to the last so an example of this would be substring (“abcdefghijk”, 2, 5) would print bcde (pseudocode starts at 1)

Boolean and Binary

  • Both have two ciphers 1 and 0 Boolean or true or false only

Bits, Bytes, Hexadecimal / Nibbles Binary Numbers: Unsigned Integer, Signed Integer, Floating Point Binary Data Abstractions: Boolean, ASCII, Unicode, RGB Data Compression: Lossy, Lossless (note discussed yet) Unit 3… Algorithm/Programming Terms ——————- Variables, Data Types, Assignment Operators Managing Complexity with Variables: Lists, 2D Lists, Dictionaries, Class Algorithms, Sequence, Selection, Iteration Expressions, Comparison Operators, Booleans Expressions and Selection, Booleans Expressions and Iteration, Truth Tables Characters, Strings, Length, Concatenation, Upper, Lower, Traversing Strings Python If, Elif, Else conditionals; Nested Selection Statements Python For, While loops with Range, with List Combining loops with conditionals to Break, Continue Procedural Abstraction, Python Def procedures, Parameters, Return Values (edited)

Iteration Notes

  • You can use iteration in notes to print out specifc items in a list -Tuple: collection that is ordered, unchangeable, allows duplicates
  • Set: collection that is unordered, unchangeable, doesn’t allow duplicates
  • Dictionary: collection that is ordered, changeable, doesn’t allow duplicates

Terms:

  • Index: a term used to sort data in order to reference to an element in a list (allows for duplicates)
  • Elements: the values in the list assigned to an index
  • Definite iteration clarifies how many times the loop is going to run, while indefinite specifies a condition that must be met

  • Else: when the condition does not meet, do statement()
  • Elif: when the condition does not meet, but meets another condition, do statement()
  • Break: stop the loop