Question

PYTHON 3

question how many object will be created? how many references? how many will be garbage collected (GC)?

z = 1+2j print(z) type(z) z. real z.imag #z. real = 4 # No setter needed #z.real = 4 Z * (3j) 1/z Z**-1 abs (z) z = 1/2 + 7

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

Python garbage collector deallocates the object if its reference count becomes zero.

# this increments the reference count to 1

# new object is created

z=1+2j

# none of the statement will create an object or reference or increment the reference count
# as these statements are just evaluations on the variable z. It is not modifying it in any way.

print(z)

type(z)

z.real

z.imag

z*(3j)

1/z

z**-1

abs(z)

# This statement decrements the reference count to 0 and hence GC is called to free the memory.

# And then a new object is created and stored in z

z=1/z+7j

Therefore 2 objects are created. The garbage collector is called once. And there were 2 references one at first line and another at the last line.

Please upvote if you like my answer and comment below if you have any queries.

Add a comment
Know the answer?
Add Answer to:
PYTHON 3 question how many object will be created? how many references? how many will be...
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
  • QUESTION 2. Suppose that S= {n e Z (Si Z)(n = 7i + 3)}, T= {n...

    QUESTION 2. Suppose that S= {n e Z (Si Z)(n = 7i + 3)}, T= {n E ZI (3j e Z)(n = 7j - 4)}. Prove that S=T.

  • Use Python WingPersonal to compile and also please give output Math and String operations Write a...

    Use Python WingPersonal to compile and also please give output Math and String operations Write a script to perform various basic math and string operations. Use some functions from Python's math module. Generate formatted output. Basic math and string operations Calculate and print the final value of each variable. a equals 3 to the power of 2.5 b equals 2 b equals b + 3 (use +=) c equals 12 c = c divided by 4 (use /=) d equals...

  • Use Python Write a script to perform various basic math and string operations. Use some functions...

    Use Python Write a script to perform various basic math and string operations. Use some functions from Python's math module. Generate formatted output. Basic math and string operations Calculate and print the final value of each variable. a equals 3 to the power of 2.5 b equals 2 b equals b + 3 (use +=) c equals 12 c = c divided by 4 (use /=) d equals the remainder of 5 divided by 3 Built-in functions abs, round, and...

  • Use the References to access important values if needed for this question moles 1. How many...

    Use the References to access important values if needed for this question moles 1. How many moles of sulfur dioxide are present in 4.49 grams of this compound? 2. How many grams of sulfur dioxide are present in 4.96 moles of this compound grams Use the References to access important values if needed for this question How many moles of sulfur dioxide are present in 9.61 × 1022 molecules of this compound? moles kilograms grams milligrams 17.9 56.5

  • s1 = 'Practice How to Use String Object' Write a python statement that splits the string,...

    s1 = 'Practice How to Use String Object' Write a python statement that splits the string, creating the following list: ['Practice', 'How', 'to', 'Use', 'String', 'Object'] 2. Assume reply references a string. The following if statement determines whether reply is equal to ‘Y’ or ‘y’: reply = input("Y or y to continue: ") if reply == "Y" and reply == "y":    print("Y --- <uppercase> has been selected. ") else:    print("y --- <lowercase> has been chosen. ") print("… continue...

  • Use the References to access important values if needed for this question. 1. How many ATOMS...

    Use the References to access important values if needed for this question. 1. How many ATOMS of nitrogen are present in 3.67 grams of nitrogen dioxide? atoms of nitrogen 2. How many GRAMS of oxygen are present in 1.02x102) molecules of nitrogen dioxide? grams of oxygen Submit Answer 2 question attempts remaining

  • Use the References to access important values if needed for this question. a. How many grams...

    Use the References to access important values if needed for this question. a. How many grams of aluminum cyanide. Al(CN)3, are present in 3.16 moles of this compound? grams b. How many moles of aluminum cyanide are present in 4.83 grams of this compound? moles

  • Use the References to access important values if needed for this question. How many ATOMS of...

    Use the References to access important values if needed for this question. How many ATOMS of phosphorus are present in 1.38 grams of tetraphosphorus decaoxide? atoms of phosphorus. 2. How many GRAMS of oxygen are present in 1.01 1023 molecules of tetraphosphorus decaoxide? grams of oxygen days grams 1. How many GRAMS of potassium sulfate are present in 4.96 moles of this compound? moles 2. How many MOLES of potassium sulfate are present in 1.67 grams of this compound?

  • Chapter 08 Python Assignment: Question 1-5 Please I need help in my python course. Question 1...

    Chapter 08 Python Assignment: Question 1-5 Please I need help in my python course. Question 1 The finally clause of a try statement a. can be used to recover from an exception b. is required c. can be used to display more information about an exception d. is executed whether or not an exception has been thrown 10 points Question 2 Which of the following is the correct way to code a try statement that catches any type of exception...

  • Use the References to access important values if needed for this question. 1. How many ATOMS...

    Use the References to access important values if needed for this question. 1. How many ATOMS of carbon are present in 4.34 moles of carbon dioxide ? atoms of carbon 2. How many MOLES of oxygen are present in 2.17x10-- molecules of carbon dioxide ? moles of oxygen SUDIT ARS Retry Entre Group group attempts remaining

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