Middle School course

Programming 301

  • GRADES 7-8
  • BEGINNER
  • WEB
  • 17 LESSONS
Slide: 1 of 20

Answer Key

Module 2: Local Variables

Module 3: Global Variables

Module 4: Super Helicopters

Module 5: Snowball Fight

Module 6: Quiz

1. What kind of variable can be easily accessed and changed by all Actors, including the Stage?

  • Global variable
  • Local variable
  • International variable
  • Local constant

2. Which of these values can be stored in a variable?

  • 1
  • 10
  • 0
  • All of these values can be stored in a variable.

3. What are the resulting values of these two variables? {"func":"blockVarSet","values":[{"type":"string","value":"variable1"},{"type":"string","value":"10"}],"next":{"func":"blockVarSet","values":[{"type":"string","value":"variable1"},{"type":"string","value":"50"}],"next":{"func":"blockVarSet","values":[{"type":"string","value":"variable2"},{"type":"string","value":"10"}],"next":{"func":"blockVarChangeBy","values":[{"type":"string","value":"variable2"},{"type":"number","value":"50"}]}}}}

  • variable1 = 50, variable2 = 60
  • variable1 = 50, variable2 = 50
  • variable1 = 10, variable2 = 50
  • variable1 = 10, variable2 = 10

4. What are the resulting values of these two variables? {"func":"blockVarSet","values":[{"type":"string","value":"variable1"},{"type":"string","value":"100"}],"next":{"func":"blockVarSet","values":[{"type":"string","value":"variable1"},{"type":"string","value":"-10"}],"next":{"func":"blockVarSet","values":[{"type":"string","value":"variable2"},{"type":"string","value":"100"}],"next":{"func":"blockVarChangeBy","values":[{"type":"string","value":"variable2"},{"type":"number","value":"-10"}]}}}}

  • variable1 = -10, variable2 = 90
  • variable1 = -10, variable2 = -10
  • variable1 = 100, variable2 = 90
  • variable1 = 100, variable2 = -10

5. What are the resulting values of these two variables? {"func":"blockVarSet","values":[{"type":"string","value":"variable1"},{"type":"string","value":"0"}],"next":{"func":"blockVarSet","values":[{"type":"string","value":"variable1"},{"type":"string","value":"50"}],"next":{"func":"blockVarSet","values":[{"type":"string","value":"variable2"},{"type":"string","value":"0"}],"next":{"func":"blockVarChangeBy","values":[{"type":"string","value":"variable2"},{"type":"number","value":"-50"}]}}}}

  • variable1 = 50, variable2 = -50
  • variable1 = 50, variable2 = 50
  • variable1 = 0, variable2 = 50
  • variable1 = 0, variable2 = -50

6. What are the resulting values of these two variables? {"func":"blockVarSet","values":[{"type":"string","value":"variable1"},{"type":"string","value":"0"}],"next":{"func":"blockVarSet","values":[{"type":"string","value":"variable1"},{"type":"string","value":"1"}],"next":{"func":"blockVarSet","values":[{"type":"string","value":"variable2"},{"type":"string","value":"0"}],"next":{"func":"blockVarChangeBy","values":[{"type":"string","value":"variable2"},{"type":"number","value":"1"}]}}}}

  • variable1 = 1, variable2 = 1
  • variable1 = 0, variable2 = 0
  • variable1 = 0, variable2 = 1
  • variable1 = 1, variable2 = 0

7. Ellen is programming a game where her dragon has a local variable called "health". She has also programmed her enemy plane to have a local variable called "health". Will changing the dragon's "health" variable affect the enemy plane’s "health" variable?

  • No, because local variables are specific to their Actor.
  • Yes, because both variables have the same name
  • Yes, because local variables can be accessed and changed easily by any Actor
  • No, because the variable resets each time it is added to a new Actor

8. Nicole has a variable called "invincibility". When she changed this variable through her dragon Actor, the variable also changed for her other Actors. Is "invincibility" a local or global variable?

  • Local
  • Global

9. Alex created a variable called "health" for his enemy plane. When he has the dragon selected, he can no longer access the "health" variable. Is "health" a local or global variable?

  • Local
  • Global

10. Jeff created a variable called "score" to keep track of the score for his game. When different types of planes are defeated, they can add different values to the score. Is "score" a local or global variable?

  • Local
  • Global

11. True or false: If I change a global variable in one Actor's code, the value of that variable has been changed for all Actors.

  • True
  • False

12. True or false: It's good practice to reset all of your variables at the start of a project.

  • True
  • False

13. True or false: If I change a local variable in one Actor's code, the value of that variable has been changed for all Actors.

  • True
  • False

14. True or false: There is no difference between the Set Variable To and Change Variable By blocks. {"func":"blockVarSet","values":[{"type":"string","value":""},{"type":"string","value":""}]}{"func":"blockVarChangeBy","values":[{"type":"string","value":""},{"type":"number","value":""}]}

  • True
  • False

15. True or false: The resulting value for this "health" variable will always be 10 after running this code block, regardless of the initial value. {"func":"blockVarChangeBy","values":[{"type":"string","value":"health"},{"type":"number","value":"10"}]}

  • True
  • False

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-15, 2-AP-16, 2-AP-17
  • CS CA: 6-8.AP.11, 6-8.AP.12, 6-8.AP.13, 6-8.AP.15, 6-8.AP.16, 6-8.AP.17
  • ISTE: 1.c, 1.d, 4.d, 5.c, 5.d, 6.b

U.K. Standards

Key stage 3
Pupils should be taught to:
  • design, use and evaluate computational abstractions that model the state and behaviour of real-world problems and physical systems
  • 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
  • undertake creative projects that involve selecting, using, and combining multiple applications, preferably across a range of devices, to achieve challenging goals, including collecting and analysing data and meeting the needs of known users
  • create, reuse, revise and repurpose 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
Key stage 4
All pupils must have the opportunity to study aspects of information technology and computer science at sufficient depth to allow them to progress to higher levels of study or to a professional career. Pupils should be taught to:
  • develop their capability, creativity and knowledge in computer science, digital media and information technology
  • develop and apply their analytic, problem-solving, design, and computational thinking skills
  • understand how changes in technology affect safety, including new ways to protect their online privacy and identity, and how to report a range of concerns

Lesson 14: Variables

Course: | Web

  • Concepts
  • Local Variables
  • Global Variables
  • Super Helicopters
  • Snowball Fight
  • Quiz

Description

An advanced introduction to programming for middle school. Introduce programming fundamentals to your class as they build two arcade-inspired games from start to finish. The Adventure Game features a knight who has to defeat enemies to reach treasure. Students program arrow keys, fluid motion, hero and enemy behavior, and winning conditions. In Dragon Attack, they define multiple levels and lives, and program a boss enemy, while learning about variables and cloning.

Topics

  • Events
  • Keyboard and mouse interaction
  • Conditional loops
  • Nested loops
  • Sending and receiving messages
  • Fluid motion
  • Parallax scrolling
  • Local and global variables
  • Functions
  • Object cloning

What Students Learn

  • Build complex multi-level games
  • Use variables to keep score
  • Use cloning to create actors programmatically
  • Build algorithms using complex conditional logic
  • Understand parallelism with multiple scripts
  • Program different behaviors for different actors
  • Publish projects to the Web
  • Troubleshoot and debug programs

Technical Requirements

* Online courses require a modern desktop computer, laptop computer, Chromebook, or Netbook with Internet access and a Chrome (29+), Firefox (30+), Safari (7+), or Edge (20+) browser. No downloads required.