Practice Sessions
Practice Sessions
3.Definition of variable?
Ans: A variable is a named storage location in a computer’s memory that holds
a value. The value stored in a variable can be changed during program
execution.
Variables:
Identifiers:
Ans: In Python, when you assign the same small integer value (like 10) to
multiple variables:
python
Copy code
A = 10
B = 10
Both A and B typically share the same memory location of id .This is because
Python optimizes memory usage by reusing memory for small integers and
some other immutable objects.
Ans: In programming, you can define a variable to hold multiple values using
different data structures:
Practice Session Test:
1. List: Stores an ordered collection of values.
2. Key Points:
Usage:
• Choose the appropriate data structure based on the type of data and
operations you need to perform.
This approach allows you to efficiently organize and manipulate data in your
programs.
Key Points:
Ans: Variables are essential in programming because they allow us to store and
manipulate data dynamically throughout our code, enabling us to: