Vocab/Blogs

Essential Knowledge

  • A variable is an abstraction inside a program that holds a value, where each variable has associated data storage that represents a single value at a time (However, if the value is a collection type such as a list, then the value can contain multiple values).
  • Variables typically have meaningful names that helps with the overall organization of the code
  • Some programming languages provide a variety of methods to represent data, which are referenced using variables 9Booleans, numbers, lists, and strings) One form of a value is better suited for representation than another. # What is a Variable?
  • A variable is an abstraction made inside a program that holds a value. These variables are used in code to refer to more comples values that the variable contains and makes the program code more organized and smoother to run. # Data Types
  • Variables have data types that store specific kinds of data depending on what is being represented. Some examples are shown below:
  • integer (numbers)
  • string (or text/letters)
  • Boolean (True/False statements) # Data Abstraction
  • Data abstraction can be created with lists.
  • Lists bundle together multiple elements and/or variables under one name are not defined with specified lengths.
  • The variables that are stored in a list do not have to be limited to one kind of variable.
  • You can also simplify code segments to better output function and make the process as a whole earlier.

What is a boolean?

  • A data type with two possible values: true or false
  • Boolean and Binary
  • So similar yet so different.
  • Boolean math and binary notation both use the same two ciphers: 1 and 0.
  • However, please note that Boolean quantities are restricted to a singlular bit (can only be either 1, or 0)
  • On the otherhand, binary numbers may be composed of many bits adding up in place-weighted form to any finite value, or size # Must Knows
  • A Boolean value is either TRUE or FALSE

Relational Operators

grade1 = 90
grade2 = 65
grade3 = 60
grade4 = 75
grade5 = 95 
print("100 == 100:",100==100)
print("Hello == Adios:","greeting"=="farewell")
print("Hello != Adios:","greeting"!="farewell")
print("Hello == Hola:","greeting"=="greeting")
print("5>=4:", 5>=4)
print ('')

# Notice that relational operators can even work on lists!
# For lists, the relational operator compares each respective component until an answer is derived

print("['a','b','c'] > ['x','y','z']:", ['a','b','c'] > ['x','y','z'])
print("[1,2,3,5] > [1,2,3,4]:", [1,2,3,5] > [1,2,3,4])
print("[1,2,3,5] < [1,2,3,4]:", [1,2,3,5] < [1,2,3,4])
print("[1,2,3,5] == [1,2,3,4]:", [1,2,3,5] == [1,2,3,4])
100 == 100: True
Hello == Adios: False
Hello != Adios: True
Hello == Hola: True
5>=4: True

['a','b','c'] > ['x','y','z']: False
[1,2,3,5] > [1,2,3,4]: True
[1,2,3,5] < [1,2,3,4]: False
[1,2,3,5] == [1,2,3,4]: False

Logical Operators

  • These types of operators don't necessarily deal with equivalent/non-equivalent values, but they rather work on operands to produce a singular boolean result

  • AND : returns TRUE if the operands around it are TRUE

  • OR : returns TRUE if at least one operand is TRUE
  • NOT : returns TRUE if the following boolean is FALSE
print("1 > 2 or 5 < 12:",)
# Output TRUE  using OR ^


# Output FALSE using NOT
print("24 > 8:",)

# Output FALSE using AND
print("10 > 20:",) 

Conditional Statements

x = 20
y = 10
if x > y:
    print("x is greater than y")
protein = 25
carbs = 36
sugar = 11
if (carbs >= 55 || protein <= 20 || sugar >= 15)
{
    console.log("Your lunch is too unhealthy, please pick a new one")
}
else
{
    if (carbs < 35 || protein < 25)
    {
    console.log ("This lunch is alright but try to add some more carbs or protein")
    }
    else 
    {
    if (sugar >= 11)
    {
    console.log ("Looks great but lets see if we can cut down on sugar, we don't want diabetes!")
    }
    else
    {
        console.log ("Amazing, you created a healthy lunch!!!")
    }
    }
}
  • variables - A variable is an abstraction inside a program that can hold a value. Each variable has associated data storage that represents one value at a time, but that value can be a list or other collection that in turn contains multiple values. Using meaningful variable names helps with readability of program code and understanding of what values are represented by the variables. Some programming languages provide types to represent data, which are referenced using variables.

  • data types- integer, string, float, boolean, lists, dictionaries, arrays, etc.

  • lists- Lists are used to store multiple items in a single variable.

  • dictionaries - A dictionary consists of a collection of key-value pairs. Each key-value pair maps the key to its associated value.

  • A plus sign indicates addition: a + b

  • A subtraction sign indicates subtraction: a - b

  • An asterisk/star indicates multiplication: a * b

  • A slash indicates division: a / b

  • MOD represent the Modulus operator. Returns the value after division: a MOD b

  • algorithms - finite set of instructions that accomplish a specific task, composed of sequencing, selection, and iteration.

  • sequence - a section of code is run only if a condition is met. (ex: if statements)

  • selection - repeating steps or instructions over and over again (ex: loops)

  • iteration - outline or set of steps that we do and follow in order that they are given

  • strings - a sequence of characters

  • concatenation - combines two or more strings into one

Characters, Strings, Length, Concatenation, Upper, Lower, Traversing Strings

  • Characters: display unit of information equivalent to one alphabetic letter or symbol
  • ex. a, 8, #
  • Strings: ordered sequences of characters
  • Length: the number of symbols output.
  • Concatenation: String concatenation is combining 2 or more strings to make a new strings in order to create a new string concat() in pseudocode and varys from language to language can be used to combine to strings such as concat("cookie","monster") returns cookiemonster
  • Upper: used to check if the argument contains any uppercase characters returns "True" if all characters in the string are uppercase, Otherwise, It returns "False"
  • Lower: returns the lowercase string from the given string
  • Traversing Strings: the process of going through a String one character at a time, often using loops
  • Python If, Elif, Else conditionals; Nested Selection Statements
  • If: statement executes a piece of code when one statement is false and the following statement is true
  • Elif: first if statement isn't true, but want to check for another condition
  • Else: executes if "if" isn't true
  • Nested Conditionals: when more than one decision must be made before the appropriate action can be taken

Binary Numbers: Unsigned Integer, Signed Integer, Floating Point

  • a binary digit, or bit, is the smallest unit of data unsigned: integers that don't have a sign associated with them ex. 1, 2
  • signed: A signed integer is a 32-bit datum that encodes an integer in the range [-2147483648 to 2147483647] -100, 80
  • Floating point: a positive or negative whole number with a decimal point ex. 5.5
  • Binary Data Abstractions: Boolean, ASCII, Unicode, RGB Boolean: datatype that does true or false
  • ASCII: a character encoding scheme in which each character is represented by a 7-bit (originally) or 8-bit binary sequence