Question: Python question. Which of the following statements describes the difference in how local variables and instance variables work given the following code fragment? def main():
Python question. Which of the following statements describes the difference in how local variables and instance variables work given the following code fragment?
| def main(): p = Object1(2, 3) print(p.method1()) print(p.method2()) print("done") main() |
a)Each time an Object1 method is called (such as method1() or method2()), new copies of the instance variables and the local variables are used.
b)Each time an Object1 method is called (such as method1() or method2()), the same copy of the instance variables is used, but a new copy of the local variables is used.
c)Each time an Object1 method is called (such as method1() or method2()), a new copy of the instance variables is used and the same copy of the local variables is used.
d)Each time an Object1 method is called (such as method1() or method2()), the same copy of the instance variables is used and the same copy of the local variables is used.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
