Learning Objective

Express an algorithm that uses sequencing without using a programming language

Notes

Kaylee, Ellie, Theo, Haeryn

  • Algorithms can be expressed in a variety of ways and can be executed by programs which are implemented using programming languages.
  • Every algorithm can be constructed using combinations of sequencing, selection, and iteration
  • Algorithm: finite set of instructions that accomplish a specific task, us as humans, do algorithms on a daily basis
  • Sequencing: steps in order, for example, doing the first step then the second then the third, etc.
  • Selection: programmer decides between two different outcomes
  • Iteration: having to repeat a step until that condition is fulfilled.
  • Plus sign: addition: a + b
  • Subtraction sign: subtraction: a - b
  • Asterisk/star: multiplication: a * b
  • Slash: division: a / b
  • MOD represents the Modulus operator

Hacks

numbers = [0,1,2,3,4,5,6,7,8,9,10]
evens = []

for i in numbers:
    if (numbers[i] % 2 == 0):
        evens.append(numbers[i])

print(evens)
[0, 2, 4, 6, 8, 10]

3.3 Video 1 Hacks:

  1. Sequence: all the code is running in a specific order and sequence
  2. Selection: the code is selecting the even numbers by using "[i] % 2 == 0" , "for i in numbers:"
  3. Iteration: for and if of a loop

3.3 Video 2 Hacks:

  1. A = 1 B = 7 C = 3 D = 7

  2. 1 - the value of hot is true, the value of cold is true

  3. Code Segment 1:

| pink | <-- | true |
| blue | <-- | false | | blue | <-- | pink | | pink| <-- | blue |

Answer: value of pink is true and the value of blue is also true My answer is correct because of the true and false segments.

Code Segment 2:

| fries | <--| true | | burgers | <-- | false | | burgers | <-- | fries | | fries | <-- | burgers |

Answer: value of fries is true and the value of burgers is also true My answer is correct because of the true and false segments, which make the values true.

  1. What is the value of num1 and num2?

num1 = 6 num2 = 11

3.4 Video 1 Hacks

String Homework:

Test 1:

firstName <- "Bob" lastName <- "Smith" var <- substring(firstName, 1, 1) name <- concat(lastName, var) email <- concat(name, "@gmail.com") DISPLAY(email)

What would the result be?

Hint: var = "B" name = "SmithB"

- The result would be SmithB@gmail.com

Test 2:

word1 <- "computer" word2 <- "textbooks" length1 <- len(word1)/2 length2 <- len(word2)/3 first <- substring(word1, 2, len1) second <- substring(word2, len2+3, len2) newWord <- concat(first, second) DISPLAY(newWord)

- The result would be ompuook

Reflection

For this group, I received a 1 on the hacks. I thoroughly completed all the hacks and followed and did them carefully.