0% found this document useful (0 votes)
14 views

Using Variables in Algorithms Lesson

Uploaded by

Ali Papila
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Using Variables in Algorithms Lesson

Uploaded by

Ali Papila
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Using Variables in Different

Algorithms
A Lesson on Variables, Data Types,
and Algorithms
What is a Variable?
• A variable is used for storing data.
Programmers give specific names to variables.
Once a variable is created, it can be used
throughout the program. The data in the
variable can change.

• Example: In a video game, a variable stores


the number of lives you have. Each time your
character dies, the number of lives decreases
by 1. When lives reach 0, the game is over.
Data Types
• In programming, a data type determines the
kind of value a variable can hold. Common
data types:

• 1. Integer: Whole numbers (e.g., 3, 5, 10)


• 2. String: Alphanumeric text like words or
phrases (e.g., 'Hello123')
• 3. Character: Single letters, digits, or symbols
(e.g., 'a', '5', '$')
Variables and Data Types in Action
• Example:
• 1. Variable `lives` stores an integer to track
lives in a game.
• 2. Variable `name` stores a string to hold a
player's name.
• 3. Variable `symbol` stores a character for an
avatar.
Algorithm 1
• 1. Start
• 2. Create variable `X`
• 3. Create variable `Y`
• 4. Create variable `answer`
• 5. Stop

• All variables in Algorithm 1 are created to


store integers.
Key Terminology
• Keyword: Alphanumeric
• - Data that contains both letters and numbers.

• Example: 'Code123' is alphanumeric.

You might also like