8
Question Question 8
What are three internal key-attributes of a value-variable in Python ? Explain with example.
Answer
The three internal key-attributes of a value-variable in Python are:
- Type
- Value
- Id
For example, consider this:
a = 4
The type of a is int which can be found with the built-in function type() like this:
type(a).
Value can be found using the built-in function print() like this:
print(a)
It will give the output as 4 which is value contained in variable a.
Id is the memory location of the object which can be determined using built-in function id() like this:
id(a)