Lesson 3.3

Luka

Lesson 3.3.1

What is the goal?

  • Express an algorithm that uses sequencing without using programming language.

What is an algorithms?

  • An algorithm is a finite set of instruction that accomplish a task, it can be expressed by natural language, diagrams, and various other ways.

What are the three parts of an algorithm?

  • Sequencing, selection, and iteration.

  • Every algorithm can be created by a mixture of sequencing, selection, and iteration

What is a sequence?

What is a selection?

  • A selection allows an algorithm to make a decision based on if a condition is met, an example of this is when your car is out of fuel, you go to the gas station to fill your car, but if your car is full you wouldn't go to the gas station.

What is a iteration?

  • An iteration is a loop and doing something again until a condition is met, like you put away your computer when you are finished with your work.

Hacks

  • You will describe the different parts of an algorithm, sequencing, selection, and iteration in the image below.
  • sequencing:
  • Selection:
  • Iteration:

Saavan

Mathematical Expressions

How do we represent a step-by-step algorithmic process using sequential code statements?

  • First off what is a sequential code statement?
    • Sequential statements are used in processes to specify how signals are assigned. The process is executed in order as a whole. After all the sequential statements in the process are executed the signals are assigned their new values. They execute in the order in which they appear in the process.
  • Sequencing - First step to do- Second step to do - third step to do
    • Followed in the order that the code comes in.
    • You can put numerical values within variables. You can also put variable values inside other variables
      • Ex. grade - 82
      • Ex. highScore - currentScore
    • Can also store results of operations inside of a variable
      • Ex. name - firstName + lastName
    • Can store results of a procedure call
      • Average - calcAverage (10,20,30)
    • Order of operations very important
      • Ex. grade1 - 10
      • Grade 2 - grade 1
  • Example Problem - calculate and display average of 25, 32, 42
    • Num1 - 25
    • Num2 -32
    • Num3 - 42
    • Average - (num1 + num2 + num3)/3
    • DISPLAY (Average)

Antony

Goal: Evaluate expression using arithmetic operator.

Arithmetic operator are language that use addition, subtraction, multiplication, division, and modulus operator.

The order of arithmetic operation is the same with mathematic operation(Subtraction first).

Examples of arithmetic operators:

-Addition: a+b -Subtraction: a-b -Multiplication: a*b -Division: a/b -Modulus: a MOD b (a and b can be string or number)

Examples of arithmetic operator in code:
10 + 5 * 8 / 4
20.0
(10+5) * 8 / 4
30.0
num1 = 10
num2 = 5
num3 = 7
result = num1 + num2 + num3
print(result)
22

Modulus operator divides the given numerator by the denominator to find a result,which is finding the remainder for the division(remainder has to an integer).

Operator with MOD have the same sequence with multiplication and division. In python and most programming languages, the syntax of MOD is %

Examples with use of MOD:
num1 = 12
num2 = 25
num3 = 14
result = num1 / 4 * num3 + 9 % 2 - num3
print(result)
29.0
num1 = 12
num2 = 25
num3 = 14
result = num2 % num1 * (num3+6) - 10
print(result)
10

Hack

-Evaluate the arithmetic expression or this code:

num1 = 5
num2 = num1 * 3
num3 = num2 / num1 * (9 % 2) * 4
result = (num3 % num1 + num2) % num3 * 3 / 5

print(result)
3.0

HACK for 3.3! CROSS WORD PUZZLE!

example of how to do it in your blog:

7 across - Baloney

Lesson 3.4

Matty

Goal: Evaluate expression that manipulate strings

String concatenation joins two or more strings end-to-end to make a new string

A substring is part of an existing string

Strings:
  • Ordered sequences of characters
  • some procedures may exist that can be used with strings
  • each language has its own procedures, methods, and functions.

Fun fact: Space bar is also a character.

Examples of strings in pseudocode:
  • len (str)

    • returns the number of character is str
    • len("hello") returns 5
  • concat (str1, str2)

    • returns a single string consisting of str1 followed by str 2
    • concat("hello","world") return 'hello world'
  • substring (str1, str2, length)

    • returns a substring of consecutive character from str1, starting the character at position 'start' and containing 'length' character
    • substring ("hello","world", 4,5) returns 'lo wor'

This is an example of a len substring in python:

len("HelloWorld")
10

This is an example of a concat string in python:

string1 = "Hello"
string2 = "World"
print(string1 + string2)
HelloWorld

or:

string1 = "Hello"
print(string1, "World")
Hello World

This is an example of a substring string in python:

string = "HelloWorld"
print(string[2:6])
lloW

"Challenge" problem:

(The first to answer the output.)

string1 = "degree"
string2 = " passenger"
FinalString = string1 + string2
print(FinalString[2:9])
print(len(FinalString))
print(len(FinalString[2:9]))
gree pa
16
7

There are many more functions that deal with strings, but these three are the ones that college board want you to learn. if you want to learn more about them, a google search will do the trick.


HACK! REVIEW

Hack #1

Hack #2

Hack #3

Make a new blog post and finish all of the hacks on there and submit it to the review ticket.