Integers Part 1
Summary
Materials
- Day 8 PowerPoint deck
- Math Operators with Variablesβ―Handout
- Math Operators with Variables Handout in Word
- arcade.makecode.com
- Button Counter program (for teacher)
Instructional Activities and Classroom Assessments
- Variables Review (5 minutes)
- Introduce Integers (15 minutes)
- Math Operators with Integers Tutorials (30 minutes)
- Reflection/Homework
Learning Objectives
Essential Knowledge
- CRD-2.G.1 Program documentation is a written description of the function of a code segment, event, procedure, or program and how it was developed.
- 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-2.C.1 Arithmetic operators are part of most programming languages and include addition, subtraction, multiplication, division, and modulus operators.
- AAP-2.C.2 The exam reference sheet provides a MOD b, which evaluates to the remainder when a is divided by b. Assume that a is an integer greater than or equal to 0 and b is an integer greater than 0. For example, 17 MOD 5 evaluates to 2.
- AAP-2.C.3 The exam reference sheet provides the arithmetic operators + - / , , , , and MOD. Text and Block: Β§ a + b Β§ a β b Β§ a b Β§ a / b Β§ a MOD b These are used to perform arithmetic on a and b. For example, 17 / 5 evaluates to 3.4.
- AAP-2.C.4 The order of operations used in mathematics applies when evaluating expressions. The MOD operator has the same precedence as the * and / operators.
Details
1. Variables Review (5 minutes)
- Discuss the following with students:
- What is a variable?
- A variable is container that stores information in a program.
- What types of variables are there in MakeCode?
- Sprite, integer, string, Boolean, lists.
- How do you name a variable?
- Any way you like, but make it meaningful so you know what it is later.
- What is a sprite?
- An Object that has properties that you can change, the building block of all games, adds narrative and interactivity.
- Can a variable change?
- Yes
- What is a variable?
- Remind students that:
- A variable is a container.
- Variables have names, values, and types.
- Names you create for variables should be meaningful.
2. Introduction to Variables (15 minutes)
- Define Integer Variables.
- Explain how variables in coding work like variables in math.
- Show students how to create number variables with the Variables toolbox.
- Guide students on how to create a button counter using variables.
- Explore different ways to represent the value of the B press.
3. Math Operators with Integers (25 minutes)
- Explain arithmetic operators used in coding.
- Give students the Math Operators with Variables page (via OneNote or other way).
- Direct students to Activity: Math Operators with Variables.
- Task students with completing the five tasks on the tutorial page:
- Try new values in an equation
- Basic math operators with variables
- Multiple operators and variables equation
- Conversion
- Debugging
- Encourage students to comment their code while they work.
- As students finish a task, instruct students to publish their program and then copy and paste the link to the Math Operators with Variables page.
4. Reflection/Homework
(If you run out of time, you may also assign this as individual homework.) Spend the last five minutes of class reflecting on questions at the end of the Math Operators with Variables page. Students should complete their reflection.
- In JavaScript, what is the resulting value of answer for answer = 5+3*2? Explain why the answer is not 30.
- How is putting operators and numbers into a calculator different than writing in code (example: 2+3+4*4)? Explain.
- Research and describe two other Math Operators found in the math menu in MakeCode (hover over values for more information).
- What did you learn about variables, data types, strings, and join?