(Also available in Pyret)
Students begin to program, exploring how Numbers, Strings, Booleans and operations on those data types work in a programming language. Booleans offer an excellent opportunity for students to explore the meaning and real-world uses of inequalities.
Lesson Goals |
Students will be able to…
|
Student-facing Lesson Goals |
|
Materials |
|
Preparation |
|
Key Points For The Facilitator |
|
🔗Strings and Numbers 20 minutes
Overview
Working together using a Driver/Navigator group setup, students experiment with the Editor. They explore Number and String data types, and how they behave in this programming language.
Launch
When programming in this class, you’ll be working together using the Driver/Navigator model.
-
Each group can only have one "Driver" - their hands are on the keyboard, and their job is to manage the typing, clicking, shortcuts, etc.
-
If you’re not a Driver, you’re a "Navigator" - your job is to tell the Driver where to go, what to type, etc.
-
A good Driver types only what the Navigator tells them to, and a good Navigator makes sure to give clear and precise instructions.
The Driver/Navigator Model
This model of pair programming is extremely useful for teasing apart the "thinking" step from the "typing" one. Students - especially those who are new to text-based programming or typing itself - can struggle to put their thoughts into the programming environment. This model allows them to focus on communicating their ideas, but letting the Driver focus on the coding. Likewise, the Driver has a chance to focus on syntax and programming. Finally, the requirement that ideas are translated through another person’s hands is an excellent scaffold for getting students talking about their thinking and about code.
-
Open WeScheme.
-
What do you Notice? What do you Wonder?
This screen is called the Editor, and it looks something like the diagram you see here. There are a few buttons at the top, but most of the screen is taken up by two large boxes: the Definitions Area on the left and the Interactions Area on the right.
The Definitions Area is where programmers define values and functions that they want to keep, while the Interactions Area allows them to experiment with those values and functions. This is like putting a set of function definitions on the board, and having students use those functions to compute answers on scrap paper.
Anytime we open a file or make a change in the Definitions Area, we need to click "Run" to load the program.
Clicking "Run" will also clear the Interactions Area. For now, we will only be writing programs in the Interactions Area on the right.
Investigate
Math is a language, just like English, Spanish, or any other language.
-
Languages have nouns (e.g. “ball”, “tomato”, etc.) and verbs, which are actions we can perform on these nouns (e.g. - I can “throw a ball”).
-
Math and programming have values, like the numbers 1, 2 and 3.
-
Instead of verbs, math and programming have functions, which are actions we can perform on values (e.g. - “I can square a number”).
-
-
Languages have rules for syntax.
-
In English, for example, words don’t have
!
and?
in the middle. -
In math and programming numbers don’t have
&
in them.
-
-
Languages also have rules for grammar.
-
The cat sat. is a sentence.
-
The sat cat. is nonsense, even though all the words are valid syntax.
-
The order of the words matters!
-
Keeping the importance of syntax and grammar in mind is helpful when learning to program!.
Complete Strings and Numbers.
-
Did you get any error messages? What did you learn from them?
-
Most of the error messages we’ve seen were drawing our attention to syntax errors: missing commas, un-closed strings, etc.
-
Synthesize
-
What have we learned about WeScheme?
-
Numbers and Strings evaluate to themselves.
-
Our Editor is pretty smart, and can automatically switch between showing a rational number as a fraction or a decimal, just by clicking on it!
-
Anything in quotes is a String, even something like
"42"
. -
Strings must have quotation marks on both sides.
-
-
What other questions do you have about the way Strings and Numbers work in WeScheme?
🔗Booleans 20 minutes
Overview
This lesson introduces students to Booleans, a unique data type with only two values: true
and false
, and why they are useful in both the real world and the programming environment.
Launch
What’s the answer: is 3 greater than 10?
Boolean-producing expressions are yes-or-no questions and will always evaluate to either true
(“yes”) or false
(“no”).
The ability to separate inputs into two categories is unique and quite useful!
For example: Some roller coasters with loops require passengers to be a minimum height to make sure that riders are safely held in place by the one-size-fits all harnesses. The gatekeeper doesn’t care exactly how tall you are, they just check whether you are as tall as the mark on the pole. If you are tall enough, you can ride, but they don’t let people on the ride who are shorter than the mark because they can’t keep them safe.
Similarly, when you log into your email, the computer asks for your password and checks whether it matches what’s on file. If the match is true
it takes you to your messages, but, if what you enter doesn’t match, you get an error message instead.
Brainstorm other scenarios where Booleans are useful in and out of the programming environment.
Investigate
Complete Booleans with your partner.
Students will make predictions about what a variety of Boolean expressions will return and testing them in the editor. Debrief student answers as a class.
Synthesize
-
What sets Booleans apart from other data types?
-
They can split data into two piles: the values that return true and the values that return false.
-
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.