Focusing on Selection

Selection: uses a condition that evaluates to true or false

Selection determines which part of an algorithm are executed based on a condition being true or false

Algorithm is a finite set of instructions that accomplish a specific task image

Conditional Statements

Also known as "if statements"

Can be seen as if statements or if blocks

image

Can also be seen as if else statements or if else-blocks

image

x = 20
y = 10
if x > y:
    print("x is greater than y")
x is greater than y
x = 0
y = 10
if x > y:
    print("x is greater than y")
else:
    print("x is not greater than y")
x is not greater than y

Participation

-Calculate the total sum of two numbers, if it is equal to 200, print 200, if otherwise, print the sum.

num1 =
num2 =
sum = num1 + num2