Skip to content

Instantly share code, notes, and snippets.

@Zhangerr
Created March 17, 2015 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zhangerr/96fb146ce60b9335c718 to your computer and use it in GitHub Desktop.
Save Zhangerr/96fb146ce60b9335c718 to your computer and use it in GitHub Desktop.
"Assume the following is input into the terminal:"
class A:
x = 5
def waka(self, x):
self.x = x
def p(self):
print("from p method")
print(self.x)
"Fill in the following blanks with what the interactive terminal would output. The answer may be an error; the effect of some lines may have affect subsequent lines"
x = A()
x.waka(3)
x.x
_____
y = A()
y.x
_____
A.waka(A, 37)
y.x
_____
x.x
_____
A.p = lambda s: s.x
x.p()
_____
x.p(y)
_____
y.p()
_____
y.p(x)
_____
y.p = lambda s: s.x
y.p()
_____
y.p(x)
_____
y.p(A)
_____
x.p()
_____
x.p(y)
_____
x.p(A)
_____
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment