Answer to Question #100755 in Python for Olayemi Adigun

Question #100755
Describe the difference between objects and values using the terms “equivalent” and “identical”. Illustrate the difference using your own examples with Python lists and the “is” operator.

Describe the relationship between objects, references, and aliasing. Again, create your own examples with Python lists.

Finally, create your own example of a function that modifies a list passed in as an argument. Describe what your function does in terms of arguments, parameters, objects, and references.

Create your own unique examples for this assignment.
1
Expert's answer
2019-12-25T02:56:11-0500

the variable is created in a python by means of the sign "=" where on the left part there will be a name of a variable and on right values of a variable. The variable and an object in a python are almost equivalent concepts. But there are distinctions as a python there are two types of objects:

1) unchangeable such as numerical data, lines, trains. For example at a privaivaniye pereenny values an object the having some identifier is created:

>>> a=2

>>> id(a)

1407502272

When giving the same variable of new value the identifier changes, that is a new object is created:

>>> a=2

>>> id(a)

1407502272

>>> a=5

>>> id(a)

1407502320

>>>

2) Changeable objects such as lists, dictionaries and mnozhest. For example we will appropriate to the list "a" some value and then we will equate the new variable "b" to "a", having output references to "an" and "b" we will see that they are identical:

>>> a= [1.7]

>>> b=a

>>> print (id(a), id(b))

59042120 59042120

That is els we will add an element to Speke of "b", the list "a" will change too.

But if we create the list "s" and as value we will appropriate it the list "b", then the references "an" and "c" will not be equivalent:

>>> is b

True

>>> c =list(b)

>>> an is with

False

Function:

>>> def add_value(a):

... a.append(7)

>>> b = [1, 0]

>>> add_value(b)

>>> print(b)

[1, 0, 7]the variable is created in a python by means of the sign "=" where on the left part there will be a name of a variable and on right values of a variable. The variable and an object in a python are almost equivalent concepts. But there are distinctions as a python there are two types of objects:

1) unchangeable such as numerical data, lines, trains. For example at a privaivaniye pereenny values an object the having some identifier is created:

>>> a=2

>>> id(a)

1407502272

When giving the same variable of new value the identifier changes, that is a new object is created:

>>> a=2

>>> id(a)

1407502272

>>> a=5

>>> id(a)

1407502320

>>>

2) Changeable objects such as lists, dictionaries and mnozhest. For example we will appropriate to the list "a" some value and then we will equate the new variable "b" to "a", having output references to "an" and "b" we will see that they are identical:

>>> a= [1.7]

>>> b=a

>>> print (id(a), id(b))

59042120 59042120

That is els we will add an element to Speke of "b", the list "a" will change too.

But if we create the list "s" and as value we will appropriate it the list "b", then the references "an" and "c" will not be equivalent:

>>> is b

True

>>> c =list(b)

>>> an is with

False

Function:

>>> def add_value(a):

... a.append(7)

>>> b = [1, 0]

>>> add_value(b)

>>> print(b)

[1, 0, 7]the variable is created in a python by means of the sign "=" where on the left part there will be a name of a variable and on right values of a variable. The variable and an object in a python are almost equivalent concepts. But there are distinctions as a python there are two types of objects:

1) unchangeable such as numerical data, lines, trains. For example at a privaivaniye pereenny values an object the having some identifier is created:

>>> a=2

>>> id(a)

1407502272

When giving the same variable of new value the identifier changes, that is a new object is created:

>>> a=2

>>> id(a)

1407502272

>>> a=5

>>> id(a)

1407502320

>>>

2) Changeable objects such as lists, dictionaries and mnozhest. For example we will appropriate to the list "a" some value and then we will equate the new variable "b" to "a", having output references to "an" and "b" we will see that they are identical:

>>> a= [1.7]

>>> b=a

>>> print (id(a), id(b))

59042120 59042120

That is els we will add an element to Speke of "b", the list "a" will change too.

But if we create the list "s" and as value we will appropriate it the list "b", then the references "an" and "c" will not be equivalent:

>>> is b

True

>>> c =list(b)

>>> an is with

False

Function:

>>> def add_value(a):

... a.append(7)

>>> b = [1, 0]

>>> add_value(b)

>>> print(b)

[1, 0, 7]the variable is created in a python by means of the sign "=" where on the left part there will be a name of a variable and on right values of a variable. The variable and an object in a python are almost equivalent concepts. But there are distinctions as a python there are two types of objects:

1) unchangeable such as numerical data, lines, trains. For example at a privaivaniye pereenny values an object the having some identifier is created:

>>> a=2

>>> id(a)

1407502272

When giving the same variable of new value the identifier changes, that is a new object is created:

>>> a=2

>>> id(a)

1407502272

>>> a=5

>>> id(a)

1407502320

>>>

2) Changeable objects such as lists, dictionaries and mnozhest. For example we will appropriate to the list "a" some value and then we will equate the new variable "b" to "a", having output references to "an" and "b" we will see that they are identical:

>>> a= [1.7]

>>> b=a

>>> print (id(a), id(b))

59042120 59042120

That is els we will add an element to Speke of "b", the list "a" will change too.

But if we create the list "s" and as value we will appropriate it the list "b", then the references "an" and "c" will not be equivalent:

>>> is b

True

>>> c =list(b)

>>> an is with

False

Function:

>>> def add_value(a):

... a.append(7)

>>> b = [1, 0]

>>> add_value(b)

>>> print(b)

[1, 0, 7]the variable is created in a python by means of the sign "=" where on the left part there will be a name of a variable and on right values of a variable. The variable and an object in a python are almost equivalent concepts. But there are distinctions as a python there are two types of objects:

1) unchangeable such as numerical data, lines, trains. For example at a privaivaniye pereenny values an object the having some identifier is created:

>>> a=2

>>> id(a)

1407502272

When giving the same variable of new value the identifier changes, that is a new object is created:

>>> a=2

>>> id(a)

1407502272

>>> a=5

>>> id(a)

1407502320

>>>

2) Changeable objects such as lists, dictionaries and mnozhest. For example we will appropriate to the list "a" some value and then we will equate the new variable "b" to "a", having output references to "an" and "b" we will see that they are identical:

>>> a= [1.7]

>>> b=a

>>> print (id(a), id(b))

59042120 59042120

That is els we will add an element to Speke of "b", the list "a" will change too.

But if we create the list "s" and as value we will appropriate it the list "b", then the references "an" and "c" will not be equivalent:

>>> is b

True

>>> c =list(b)

>>> an is with

False

Function:

>>> def add_value(a):

... a.append(7)

>>> b = [1, 0]

>>> add_value(b)

>>> print(b)

[1, 0, 7]the variable is created in a python by means of the sign "=" where on the left part there will be a name of a variable and on right values of a variable. The variable and an object in a python are almost equivalent concepts. But there are distinctions as a python there are two types of objects:

1) unchangeable such as numerical data, lines, trains. For example at a privaivaniye pereenny values an object the having some identifier is created:

>>> a=2

>>> id(a)

1407502272

When giving the same variable of new value the identifier changes, that is a new object is created:

>>> a=2

>>> id(a)

1407502272

>>> a=5

>>> id(a)

1407502320

>>>

2) Changeable objects such as lists, dictionaries and mnozhest. For example we will appropriate to the list "a" some value and then we will equate the new variable "b" to "a", having output references to "an" and "b" we will see that they are identical:

>>> a= [1.7]

>>> b=a

>>> print (id(a), id(b))

59042120 59042120

That is els we will add an element to Speke of "b", the list "a" will change too.

But if we create the list "s" and as value we will appropriate it the list "b", then the references "an" and "c" will not be equivalent:

>>> is b

True

>>> c =list(b)

>>> an is with

False

Function:

>>> def add_value(a):

... a.append(7)

>>> b = [1, 0]

>>> add_value(b)

>>> print(b)

[1, 0, 7]the variable is created in a python by means of the sign "=" where on the left part there will be a name of a variable and on right values of a variable. The variable and an object in a python are almost equivalent concepts. But there are distinctions as a python there are two types of objects:

1) unchangeable such as numerical data, lines, trains. For example at a privaivaniye pereenny values an object the having some identifier is created:

>>> a=2

>>> id(a)

1407502272

When giving the same variable of new value the identifier changes, that is a new object is created:

>>> a=2

>>> id(a)

1407502272

>>> a=5

>>> id(a)

1407502320

>>>

2) Changeable objects such as lists, dictionaries and mnozhest. For example we will appropriate to the list "a" some value and then we will equate the new variable "b" to "a", having output references to "a" and "b" we will see that they are identical:

>>> a= [1.7]

>>> b=a

>>> print (id(a), id(b))

59042120 59042120

That is els we will add an element to Speke of "b", the list "a" will change too.

But if we create the list "s" and as value we will appropriate it the list "b", then the references "an" and "c" will not be equivalent:

>>> is b

True

>>> c =list(b)

>>> an is with

False

Function:

>>> def add_value(a):

... a.append(7)

>>> b = [1, 0]

>>> add_value(b)

>>> print(b)

[1, 0, 7]the variable is created in a python by means of the sign "=" where on the left part there will be a name of a variable and on right values of a variable. The variable and an object in a python are almost equivalent concepts. But there are distinctions as a python there are two types of objects:

1) unchangeable such as numerical data, lines, trains. For example at a privaivaniye pereenny values an object the having some identifier is created:

>>> a=2

>>> id(a)

1407502272

When giving the same variable of new value the identifier changes, that is a new object is created:

>>> a=2

>>> id(a)

1407502272

>>> a=5

>>> id(a)

1407502320

>>>

2) Changeable objects such as lists, dictionaries and mnozhest. For example we will appropriate to the list "a" some value and then we will equate the new variable "b" to "a", having output references to "a" and "b" we will see that they are identical:

>>> a= [1.7]

>>> b=a

>>> print (id(a), id(b))

59042120 59042120

That is else we will add an element to Speke of "b", the list "a" will change too.

But if we create the list "с" and as value we will appropriate it the list "b", then the references "a" and "c" will not be equivalent:

>>> a is b

True

>>> c =list(b)

>>> a is с

False

Function:

>>> def add_value(a):

... a.append(7)

>>> b = [1, 0]

>>> add_value(b)

>>> print(b)

[1, 0, 7]


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS