Explain how to copy an object in Python.
Answer / chaitanya
There are two ways in which objects can be copied in python.
Shallow copy & Deep copy.
Shallow copies duplicate as minute as possible whereas Deep copies duplicate everything.
If a is object to be copied then
-copy.copy(a) returns a shallow copy of a.
-copy.deepcopy(a) returns a deep copy of a.
| Is This Answer Correct ? | 0 Yes | 0 No |
How do you sort in python 3?
How will you use python to read a random line from a file?
What are the two main types of functions in python?
What is kwargs in python?
What is constructor in python?
Explain about indexing and slicing operation in sequences?
What is abstraction in python?
Is python sorted stable?
What is python’s standard way of identifying a block of code?
Why do list comprehensions write to the loop variable, but generators don’t?
Differentiate between deep and shallow copy in python?
How do I use strftime in python?