What does the following python code print out?
# python code start
fruit1 = "apples"
fruit2 = "oranges"
fruit3 = fruit2
fruit2 = fruit1
if (fruit3 == fruit2):
print 34
elif (fruit2 == fruit1):
print 72
elif (fruit3 == fruit1):
print 9
else:
print 119
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The answer is 72 .
By the time the first 4 assignment statements are done, fruit1 = "apples", fruit2 = "apples", and fruit3 = "oranges". Thus fruit2 equals fruit1, and the "print 72" statement gets executed.