In this video, I imagined that the students have already learned how to work with numeric data, and have written a function. Here I introduce a new kind of data (logical) and show how to write ifelse statements.
In this example, I actually made a mistake! I had no idea that return()
is only for the inside of functions. I typed in the body of the function sign()
in the Conditional Programming lesson, but didn’t enclose it in a function. So I got to practice live debugging! I’d love some feedback on that.
When I was teaching this, I felt like the lesson as given didn’t break it down into enough steps. I think we should
- teach the students
TRUE
andFALSE
(i.e. logical values and where they come from) - logical tests
2 < 4
etc. - a simple
if
statement if
andelse
- wrapping in a function (assuming functions already covered; thus creating a link back).