Lesson Outcomes
After completing this practical lesson, learners will be able to:
- Explain variables and constants in programming
- Create and initialise variables
- Declare and use constants
- Apply different data types
- Modify variable values during program execution
- Verify and correct variable-related errors
Overview
Variables and constants are fundamental programming components used to store and manage data during program execution. Variables store values that may change while constants store fixed values that remain unchanged during program operation.
This practical lesson introduces learners to variables, constants, data types, assignment operations, and value manipulation used in programming and Robotic Process Automation (RPA) environments. Learners will complete practical coding activities involving variable declaration, data storage, calculations, and debugging.
Scenario: Learner Registration System
A software development company is building a learner registration system that stores learner names, IDs, fees, and registration information.
The system requires variables to store changing information and constants to store fixed values such as VAT percentages and registration fees.
Learners are required to create and manage variables and constants used in the system.
PA0401 — Create and Initialise Variables
Variables are used to store changing information during program execution.
Tools/Resources
- IDE or coding environment
- PC or laptop
- Programming documentation
Activity Instructions
- Create variables with appropriate names.
- Assign values to the variables.
- Display variable values.
- Verify outputs.
Example
learner_name = "John"
learner_age = 21
print(learner_name)
print(learner_age)
Expected Outcome
Variables are created and initialised correctly.
Evidence Required
- Screenshot of variable declarations
- Screenshot of displayed outputs
PA0402 — Apply Different Data Types
Variables may store different types of data.
Tools/Resources
- IDE
- Notebook
- Programming reference material
Activity Instructions
- Create variables using different data types.
- Assign suitable values to each variable.
- Display the stored values.
- Verify outputs.
Example
name = "Sarah" # String
age = 25 # Integer
height = 1.75 # Float
registered = True # Boolean
Expected Outcome
Different data types are applied correctly.
Evidence Required
- Screenshot of variable data types
- Screenshot of outputs
PA0403 — Create and Use Constants
Constants store values that should not change during program execution.
Tools/Resources
- IDE
- Programming documentation
- Notebook
Activity Instructions
- Create constant values.
- Use constants in calculations.
- Display the outputs.
- Verify all results.
Example
VAT_RATE = 15
amount = 200
vat = amount * VAT_RATE / 100
print(vat)
Expected Outcome
Constants are created and used correctly.
Evidence Required
- Screenshot of constant declarations
- Screenshot of calculations using constants
PA0404 — Modify Variable Values
Variables may change during program execution.
Tools/Resources
- IDE
- Calculator
- Notebook
Activity Instructions
- Create variables with initial values.
- Modify the values during execution.
- Display updated values.
- Verify outputs.
Example
count = 5
count = count + 1
print(count)
Output
6
Expected Outcome
Variable values are updated successfully during execution.
Evidence Required
- Screenshot of updated variables
- Screenshot of outputs
PA0405 — Perform Calculations Using Variables
Variables are commonly used in programming calculations.
Tools/Resources
- IDE
- Calculator
- Notebook
Activity Instructions
- Create numerical variables.
- Perform arithmetic calculations.
- Store calculation results in variables.
- Display the outputs.
Example
price = 250
quantity = 3
total = price * quantity
print(total)
Output
750
Expected Outcome
Calculations using variables are completed correctly.
Evidence Required
- Screenshot of calculation code
- Screenshot of outputs
PA0406 — Identify and Correct Variable Errors
Incorrect variable usage may cause program errors.
Tools/Resources
- IDE
- Debugging tools
- Error logs
Activity Instructions
- Review provided code.
- Identify variable-related errors.
- Correct the errors.
- Execute the corrected program.
Example
Incorrect Code
price = 100
print(total)
Correct Code
price = 100
total = price
print(total)
Expected Outcome
Variable-related errors are identified and corrected successfully.
Evidence Required
- Screenshot of incorrect code
- Screenshot of corrected code
- Screenshot of successful execution
Key Notes
- Variables store changing information.
- Constants store fixed values.
- Different data types store different kinds of information.
- Variables may change during execution.
- Clear variable naming improves program readability.
- Incorrect variable usage may cause program errors.
- Debugging improves program reliability.