Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Copy by reference versus shallow copy Consider this code: import copy class ThreeNumbers: def init _ ( self , n 1 : float, n 2

Copy by reference versus shallow copy
Consider this code:
import copy
class ThreeNumbers:
def init _(self, n1: float, n2: float, n3: float):
self.number1= n1
self.number2= n2
self.number3= n3
def main()
object1= ThreeNumbers(2,3.14159,2.71828)
object2= object1
object3= copy.copy(object1)
object1.number1=9
object2.number1=47
print(object1)
print(object2)
print(object3)
print(object1.number1, object2.number1, object3.number1)
if _name_=="__main__":
main()
Draw Complete Diagram / Call Stack
T/F Line 12 copies a reference (memory address)
b. T/F Line 13 performs a deep copy
c. T/F Lines 16-18 output a memory address since __str__ was not implemented in the class ThreeNumbers.
d. What does line 19 output? e. Draw the memory diagram

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are the objectives of performance appraisal ?

Answered: 1 week ago

Question

State the uses of job description.

Answered: 1 week ago

Question

6. Testing equipment that will be used in instruction.

Answered: 1 week ago