Created
March 17, 2015 05:30
-
-
Save Zhangerr/96fb146ce60b9335c718 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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