Question

Describe the difference between objects and values using the terms “equivalent” and “identical”. Illustrate the difference...

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(1) Differences between objects and value interms of identical and equivalent: Objects Value Objects nothing but instance of
looking like identical then check the equality of two variables. From the above outputs are secondList) >> print (firstList T
(2) Aliasing: Aliases act as pointers in some case and aliases are used in the case of lists and dictionaries. Alias can defiReferences: Reference is symbolic name representation of a python variable that reference to an object. Once object is create
Sample Output:

Objects:

>>> object1 = [1,2,3,4] >>>object1 [1, 2, 3, 4

References:

> object2 object1 >>

Aliasing:

>> object2 object1 > >>> object2 [1, 2, 3, 4 >>>print (id (object1)) 66211472 >> print (id (object2)) 66211472 >>

(3) argument Function that modifies a list passed is an class example Demo (): #Implementation of example method with argumen

Arguments The variable is declared at method declaration is called arguments. An argument is passed to a function, here from

Code Image:

class exampleDemo () #Implementation of example method #with argument as def test (self,listArgument): #Display statement pri

Sample Output:

Before modification of list [1, 2, 3, 4] After modification of list [5, 6, 7, 8]

Code to Copy:

class exampleDemo():

#Implementation of example method

#with argument as listArgument

def test(self,listArgument):

#Display statement

print("Before modification of list ",listArgument)

#assigning new values

listArgument[:] = [5,6,7,8]

#Display statement

print("After modification of list ",listArgument)

  

#creation of an object for exampleDemo class

object1 = exampleDemo()

#Declare listArgument as list type

#and assign values

arg1 = [1,2,3,4]

#call example method with parameter type

#listArgument

object1.test(arg1)

Add a comment
Know the answer?
Add Answer to:
Describe the difference between objects and values using the terms “equivalent” and “identical”. Illustrate the difference...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT