1 Answers
📚 Topic Summary
Variables are like containers that hold information in a computer program. A global variable is one that can be accessed from anywhere in your code. Think of it like a public announcement that everyone can see. A local variable, on the other hand, is only accessible within the specific part of the code where it's defined, like a secret message only you and a friend know. Understanding the difference is key to writing clean and organized programs!
🧠 Part A: Vocabulary
Match the terms with their correct definitions:
| Term | Definition |
|---|---|
| 1. Global Variable | A. Accessible only within a specific part of the code |
| 2. Local Variable | B. The process of giving a variable a value |
| 3. Scope | C. Accessible from anywhere in the code |
| 4. Assignment | D. The region where a variable is valid. |
| 5. Function | E. A block of organized, reusable code |
✍️ Part B: Fill in the Blanks
Complete the following paragraph using the words: local, global, scope, function.
A _______ variable is defined outside of any _______, making it accessible throughout the entire program. However, a _______ variable is declared inside a function, limiting its _______ to that specific function.
🤔 Part C: Critical Thinking
Imagine you're writing a game. Would you use a global or local variable to store the player's score? Explain your choice.
Join the discussion
Please log in to post your answer.
Log InEarn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! 🚀