Wednesday, September 12, 2012

Computer programming, given the following code, what is printed? (in Python)?

Given the following code, what is printed if x, y, z, a, and b are defined as follows? (Note: You may want to reference the Python documentation to determine what some of these functions do.)

x = "If inside a circle a line"
y = "Hits the center and goes spine to spine"
z = "And the line's length is d"
a = "the circumference will be"
b = "d times 3.14159… "

if (a < b):
print "Get it?"

elif (z.find("d") == -1):
print "Aren't limericks fun?"

elif (y.isupper()):
print "They might even teach you something!"

else:
if (x.islower()):
print "Math"
elif (len(b) <= 3.14159):
print "Rocks!"

AND:

True or False:
In the previous question, it is possible to modify the last two Boolean expressions (and only the Boolean expressions, not the if-elif construct or the conditional statements) such that the string "Math Rocks!" is printed out on one line.
>>> Computer programming, given the following code, what is printed? (in Python)?