learning objective: write algorithms that uses selection without using a programming language

vocab

selection: determines which part of an algorithm are executed based on condition being true or false algorithm: a finite set of instructions that accomplish a specific task

ex determine if a number is in range

  • get number from user
  • is number greater than - and less than 10
  • if yes display number
  • if no display goodbye

participation hack:

give me different ways you would determine if a kid needs to go to tutoring

writing conditionals

format

if (condition) :

  • if the condition evaluates to true then the block of statements occurs
  • if not then no action is taken

or

if (condition) : else:

  • if the condition is true then first block is executed if false then the second black or else statement is executed

Example – multiple of 3?

number = 9

if number % 3 == 0 :
    print ("multiple of 3")
else: 
    print ("not multiple of 3")

multiple of 3

Popcorn Hack

calculate the sum of two numbers -> if the sum is greater than 100 display 100, otherwise display the sum

help you guys get started:

num 1 = num 2 =

sum = num 1 + num 2

if ():

else :