String Variables
Summary
Materials
Instructional Activities and Classroom Assessments
- Integers Review (5 minutes)
- Introduce string variables (10 minutes)
- Sprite Greets You By Name Program (15 minutes)
- Parts of Speech Program (20 minutes)
- Homework
Learning Objectives
- CRD-2.B Explain how a program or code segment functions. 4.A
- CRD-2.G Describe the purpose of a code segment or program by writing documentation. 4.A
- AAP-1.A Represent a value with a variable.β3.A AAP-1.C Represent a list or string using a variable.β3.A AAP-2.A Express an algorithm that uses sequencing without using a programming language.β2.A AAP-2.D Evaluate expressions that manipulate strings.β4.B
Essential Knowledge
- CRD-2.A.1 The purpose of computing innovations is to solve problems or to pursue interests through creative expression.
- CRD-2.B.2 A code segment is a collection of program statements that is part of a program.
- CRD-2.G.3 Programmers should document a program throughout its development.
- AAP-1.A.1 A variable is an abstraction inside a program that can hold a value. Each variable has associated data storage that represents one value at a time, but that value can be a list or other collection that in turn contains multiple values.
- AAP-1.A.2 Using meaningful variable names helps with the readability of program code and understanding of what values are represented by the variables.
- AAP-1.C.4 A string is an ordered sequence of characters.
- AAP-2.A.2 Beyond visual and textual programming languages, algorithms can be expressed in a variety of ways, such as natural language, diagrams, and pseudocode.
- AAP-2.D.1 String concatenation joins together two or more strings end-to-end to make a new string.
Details
1. Integers Review (5 minutes)
- What is an expression? It can consist of a value, a variable, an operator, or a procedure call that returns a value.
- How many values can an expression evaluate to? 1
- What is the order of operations for math operators? PEDMAS
- How is working with integers different than working with sprites? Sprites have properties.
- Did you use any of the Math blocks you researched?
2. Introduce String Variables (10 minutes)
- Define characters in programming.
- Define string in programming.
- Discuss where we see strings when we:
- Use computers
- Play computer game
- Define string variables further.
- Lead students through creating a program where a sprite uses a string.
- Introduce string concatenation.
- Change program so sprite says "Hello World."
3. Sprite Greets You By Name Program (15 minutes)
- Lead students through creating a program where a sprite greets you by name:
- With direction, students will first create the program to greet you by your first name.
- Task students to then create a program where the sprite greets you by first and last name.
- Debrief:
- How did you know what to do?
- Were your first and last name joined together without any separation?
- How did you fix it?
- Ask students to share their code, copy the link, and paste it to "My Code Segments for String Activities" page.
4. Parts of Speech Program (20 minutes)
- Introduce substring.
- Lead students through creating a program that pulls out the nouns from a sentence.
- Task students to then create a program each sprite pulls out a different part of speech from the sentence.
- Students must:
- Use the substring block.
- Optionally use the join block if there is more than one word.
- When students are finished:
- Create a link to their program using the Share button.
- Add their link to their "My Code Segments for String Activities" page.
- Depending on your class collaboration system, you can have students copy and paste their program links in an email, LMS system, Class OneNote, or other tool.
- Alternately, they can download their programs as .png files on their local computers or on a shared file system.
- Note - by default most browsers will download files to the "Download" folder on a computer.β― You can change this behavior if you want by configuring the browser settings (instructions in PowerPoint deck).
5. Homework
- How is working with strings different that working with integers or sprites?
- Think of all the places in real life you enter a string and it triggers an action
- Research some of the text blocks by hovering, right click, and select help