Programming 301 Lesson Plan

Lesson: Variables
Time: 60+ mins

Introduction

In this lesson, students will learn about variables and how variables can be used to keep track of scores. Coding concepts from this lesson include: Set/Change Variables and Local/Global Variables.

New Code Blocks

  • : Set the value of the specified variable.
  • : Change the specified variable by the specified amount.

Vocabulary

  • Variables: A value or piece of information that is stored and can be changed.
  • Local variable: A variable that can be accessed and changed only by the Actor who owns the variable.
  • Global variable: A variable that can be accessed and changed by all Actors as well as the Stage. In Tynker, global variables are defined on the Stage.

Objectives

Students will...
  • Create games and projects using variables
  • Use code blocks to solve a puzzle module
  • Create a snowball fight game

Materials

  • Computers, laptops, or mobile devices (1 per student) with student account access to Tynker.com

Warm-Up (15 minutes)

  • Tell students that they’re going to learn about variables today using Tynker, and in the last project, they’ll create a snowball fight game. Next, ask students to answer this short-response question:
    • If you created a snowball game using Tynker, what would it be like? What is the goal? What Actors would you include? List at least two code blocks you would use and describe how you would apply them to your game.

Activities (45 minutes)

Facilitate as students complete all Variables modules on their own:
1. Concepts (Video)
  • Dan, the dragon rider, introduces two coding concepts:
    • Set/Change Variables- The “set variable” block changes the variable’s value to the specified value, without looking at the variable’s current value. The “change variable” block changes the variable’s value by adding or subtracting from the current value of the variable.
    • Local/Global Variables- Local variables are used for only one Actor. When variables are used for more than one Actor, or for every Actor, it is called a global variable.
2. Local Variables (DIY)
  • In this DIY (do-it-yourself) project, students will follow step-by-step directions to learn how local variables can be used to represent an Actor’s health.
  • Point out to your students that the plane’s explosion animation activates when the health variable reaches zero.
  • Optional: Remind students that local variables can be accessed and changed only by the Actor who owns the variable.
3. Global Variables (DIY)
  • In this DIY project, students will learn how to keep score using global variables. Each time an enemy plane is defeated, the user’s score will increase by 100 points.
  • Emphasize to students that a global variable can be accessed and changed by all Actors as well as the Stage. In Tynker, global variables are defined on the Stage.
4. Super Helicopters (Puzzle)
  • To solve this puzzle module, students will need to program the helicopters to lose health when hit and explode when they run out of health.
  • Give a hint: Ask students, “What happens when the helicopter’s health is less than 1?” (Answer: The helicopter explodes.)
5. Snowball Fight (DIY)
  • In this DIY project, students will apply variable concepts learned in this lesson by creating a snowball fight game! Activities include adding a health variable to the different bird Actors and adding a “score” variable to keep score of the game.
  • If students finish early, encourage them to find a friend to play their game.
6. Quiz (Multiple-choice)
  • Students will answer 5 multiple-choice questions to review concepts from this lesson.

Extended Activities (10 minutes)

Review
Ask students...
  • True or false: A variable is a value or piece of information that is stored and can change over time. (Answer: True.)
  • True or false: Local variables are used for more than one Actor. (Answer: False. A local variable is a variable that is only used for one Actor, whereas a global variable is a variable that is used for more than one Actor in the program.)
  • Who can describe one way they used variables? (Example: We used a local variable to set an enemy plane’s health.)

U.S. Standards

  • CCSS-Math: MP.1, MP.2
  • CCSS-ELA: RI.7.4, RI.8.4, 6-8.RST.3, 6-8.RST.4, 6-8.RST.7
  • CSTA: 2-AP-10, 2-AP-11, 2-AP-13, 2-AP-16, 2-AP-17
  • CS CA: 6-8.AP.10, 6-8.AP.11, 6-8.AP.13, 6-8.AP.17
  • ISTE: 1.c, 1.d, 4.d, 5.c, 5.d, 6.b

U.k. Standards

Key Stage 3 (Years 7-9)
  • Understand several key algorithms that reflect computational thinking [for example, ones for sorting and searching]; use logical reasoning to compare the utility of alternative algorithms for the same problem.
  • Create, re-use, revise and re-purpose digital artefacts for a given audience, with attention to trustworthiness, design and usability.
  • Understand a range of ways to use technology safely, respectfully, responsibly and securely, including protecting their online identity and privacy; recognise inappropriate content, contact and conduct and know how to report concerns.
This course is not part of your plan. Please upgrade to view all answer keys

Class Presentations

These student-facing slide presentations help educators seamlessly run Tynker lessons in a virtual or physical classroom setting. Each lesson has its own set of slides that introduce the big ideas, suggest unplugged activities, and include a section for each activity module. While running lesson slides, you can switch back and forth between the activity, the slides, answer keys and other lesson materials.
A sample slide presentation is available for your review. Please log in to view all the class presentations available with your plan..
Lesson 1
Introduction
27 Slides
Lesson 2
Animated Motion
20 Slides
Lesson 3
Actor Positioning
19 Slides
Lesson 4
Motion and Tracking
18 Slides
Lesson 5
Conditional Loops
23 Slides
Lesson 6
Show and Hide
20 Slides
Lesson 7
Actor Properties
18 Slides
Lesson 8
Nested Loops
18 Slides
Lesson 9
Messaging
21 Slides
Lesson 10
Start Screen and Controls
21 Slides
Lesson 11
Shoot Projectiles
21 Slides
Lesson 12
Parallax Scrolling
18 Slides
Lesson 13
Cloning
19 Slides
Lesson 14
Variables
20 Slides
Lesson 15
Powerups and Effects
20 Slides
Lesson 16
Boss Battle
18 Slides
Lesson 17
Finishing Touch
15 Slides