π‘ Activity Solution
π‘ Activity Solution
1οΈβ£ What is a Variable, and why do we need it?
- A variable is a container in memory that stores data temporarily while the program runs.
- We need it to hold, update, and reuse information such as names, numbers, or results.
2οΈβ£ What is a Constant, and why do we need it?
- A constant is a read-only container whose value cannot change once assigned.
- We need it to protect fixed values (like Ο = 3.14) from being modified accidentally.
3οΈβ£ What is a Memory Cell?
- A memory cell is a small storage unit in RAM that holds the binary bits of a variableβs value.
4οΈβ£ What is an Identifier?
- An identifier is the name given to a variable or constant so the programmer can refer to it easily (e.g.,
Age,PI).
5οΈβ£ What is a Memory Address, and what is its relation to location in memory?
- A memory address is the exact location of a memory cell inside the computerβs RAM.
- Each variable is stored at a unique address β just like houses have unique addresses.
6οΈβ£ Which numbering system is used to represent memory addresses?
- Memory addresses are represented in hexadecimal (base 16) form, e.g.,
0x7FFF89A2.
7οΈβ£ Mention the primary types of variables.
- Integer (Int) β whole numbers (e.g.,
25) - Float/Double β decimal numbers (e.g.,
3.14) - String β text (e.g.,
"Omar") - Boolean β True/False (e.g.,
True)
8οΈβ£ What are the number types, and give examples for each.
- Integer (Int): Whole numbers (e.g.,
β10,0,150) - Float (Decimal): Numbers with fractions (e.g.,
3.5,7.25)
9οΈβ£ What is a String, and give an example of it.
- A String stores text or characters, written between quotation marks.
Example:"Hello World"or"Mohammed".
π What is a Boolean, and give an example of it.
- A Boolean represents True or False values used in decisions.
- Example:
IsStudent = TrueorHasLicense = False.
5 comments