Mathematical expressions and string notes

Algorithm

  • Sequencing
    • Algorithms do tasks in the order of specification
  • Selection
    • Helps choose two different outcomes based off a decision
  • Iteration
    • If a condition is true, then the code can repeat
    • Ex: For loops and while loops are both iterations

Arithmetic Operations

  • Basic Operations
    • Addition(+), subtraction(-), multiplication(*), division(/), modulus (%)
  • Operations can be done on variables
  • Order of Operations
    • performed in the same order as operations in math
  • Every time the value assigned to a variable is changed, it overrides the last value which was assigned to the same variable
    • This is why it is important to keep track of the value of variables

Strings

  • What is a string?
    • a collection of characters (anything from numbers, letters, spaces, special symbols, etc.)
    • Different string procedures (python)
      • len() finds the length of the string
      • lower() convert to lowercase
    • Different string procedures (pseudocode)
      • len() finds the length of the string
      • concat() returns a string made of the concatenated strings
        • ex. concat(“string1”, “string2”) would return string1string2
      • substring() returns the characters from the string beginning at the first position to the last
        • ex. substring (“abcdefghijk”, 2, 5) would print bcde (psuedo code starts at 1)