Conditionals & Input

(ToC)


Video Introduction (5 minutes) <<--- Watch this video first, then

English IDE <<--- Click this link and rewrite (improve) your first program here.

When it runs without errors or warnings, Raise your hand in Zoom to continue.

If you didn't watch the video, or if you didn't pay much attention, and if you cannot figure out why your program does not run properly, you might reconsider: Watch the Video.

Or, if you are like me and prefer to read at your own pace instead of whatever pace set in some video, You can read the transcript (and probably come out ahead of the non-readers).

Video Transcript: 2. Conditionals & Input

I'm assuming you ran your first English program, maybe it looks something like this, with jam on your sandwich.
Open pantry cabinet.
get jam
Open other cabinet.
Open drawer.
Get knife
get plate
get bread
Open bread.
Get piece of bread.
Open jam
get jam on knife
spread jam on bread
Get another piece of bread.
get peanut butter
Open PB.
get PB on knife
spread PB on bread
Put bread pieces together.


It's a start. But the real world is not a straight line like this program. We have turns and switches, conditions and curlicues.

Things Happen, and we need to deal with it. Maybe you ran out of grape jelly, so you must make your sandwich from strawberry. Or maybe grape is boring, let's try peach today. You can do that: "I feel like strawberry today," and you alone know how you feel.

So let's pretend we are making this sandwich for your finicky brother or cousin or whatever, and he's on a rigid schedule: Monday it's grape, Tuesday it's peach, Wednesday it's strawberry.

On the second line of my program, where it says

get jam
Change that one line to these three lines:
if it is Monday get grape
if it is Tuesday get peach
any other day get strawberry
Do you see the calendar near the left edge of the Kitchen computer? What day is it when you run this revised program? Did it choose the right jam?

How would you know if the other two lines worked correctly? I guess you could wait until that day of the week rolled around, then run it gain, but there's an easier cheat: Insert in front of the program, before the first line

it is Tuesday
(or whatever day it isn't), then try it again. Did you see the day change on the calendar? You can also change the month, like
it is December
or the time on the wall clock over the fridge:
it is 11:30
But testing the exact time is difficult, it might be better to try for before or after a particular time.

So experiment some with changing how you make your sandwich, based on the date and time. Show us your work!
 

[2021 August 9d]