The lesson we're doing right now is called Conditionals with Cards
So if you all can stay quiet for 20 seconds with no noises
I will give you recess, an extra 5 minutes of recess
Go!
...
Whoah, you did it!
You guys re gonna get an extra 5 minutes of recess today!
That is so neat.
OK. So, I have a question for you
I just said...
"If (something)
then (something else"
Right?
So what did I say?
If... Student: If you were quiet for 20 seconds...
I'll give you an extra 5 minutes of recess
If class is quiet
Then I'll give you extra recess.
If (something is true),
then (something else will happen)
"It's a reward, if you do something good, you get a reward back!"
"If you do something bad, you get consequences"
That was very good
So did you hear that?
Not only did she have an if,
She said "(or else)".
Has someone ever said:
If ... or else ...
Yeah? Do your parents do that?
Class: yeah!
Ok, so we have an "(else)"
What was the "(else)"?
If...
The class is quiet, extra recess
Else...
Student: do we actually get extra recess?
Yes, you actually get extra recess Class: yay!
There's no way I'd promise you that if you don't get extra recess
Student: if class is quiet they do (get extra recess),
if class is not quiet they don't get extra recess.
Teacher: no extra recess.
And I could have said
Or "(else)" you're going to clean up the classroom. Right?
Class boos Teacher: there are lots of different things I could have said
This is called
a conditional.
Do you guys know what a condition is?
So, have you ever heard, maybe your parents, say:
"I will on one condition, you pick up your shoes right now."
Right? Something like that?
A condition is either something that happens, or it doesn't.
It's true, or it's false.
So what we put in here
is something that can either be "True", or "False"
So, when you guys were quiet for 20 seconds
Was it
True, or False?
Class: True
So we got to do this part (extra recess)
Now if it were False
and you weren't quiet?
Then what would we have done?
Student: the bottom part (no extra recess)
Would we ever do both?
Class: no!
That doesn't make sense, right?
Student: unless we're quiet for 10 seconds?
Then we would do half and half
Other student: but you talked.
Teacher: so that's a compromise
and that would have fallen somewhere in the middle (between "if" and "else").
So we could have done something like
Else if (class kinda quiet)
half extra recess
and then
we would've had the "else"
that was "nothing extra".
Right? So what you guys came up with is these "if", "elseif", and "else" statements
So you have one condition (the "if"),
you have a whole separate condition that we only care about if this one is "False"
And then, if this one's "False"
and this one's "False", then what do we do?
We go to the "else" statement.
And that captures everything else, ok?
Ok, so now we are going to do an activity
where you guys get to use that idea of "if" and "else"
Ok, so this first program here says
If card is red, award your team one point,
else, award other team one point. Right?
So, if you draw a red card, what happens?
A lot of times teachers are so used to hearing
"(if... then...)"
that "(if... else...)"
sounds unnatural.
If you remember that the "then" part is
what you do when your condition is "true" then it becomes a lot more comfortable
So we were able to use those playing cards to make "if" statements
and play a game.
And you had a game
so that when if you drew a red card you did one thing,
otherwise you did something else.
In computer science, we call that a conditional,
and it helps us make decisions in our program.
Because, is a computer as smart as we are?
Class: no!
Teacher: no,
it's fast but they aren't very good at making their own decisions
unless you tell it what you want it to decide.
So that's how we use a conditional
so that the computer can figure out what's gonna happen
and run the program accordingly.
Subtitles by the Amara.org community