Question:
computer programming, given the following code, what is printed? (in Python)?
anonymous
2012-09-11 18:45:41 UTC
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.
Three answers:
James Bond
2012-09-11 18:57:18 UTC
I dont know what you are doing. I have corrected. Now no syntactical errors. Check logic of your code





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!"
kuechle
2016-07-27 22:54:47 UTC
Ok .. Exceptional factor is to start with Visial common .. Thats what they provide students at some schools for grade 10 .. U will likely be learning the fundamentals there and the good judgment of programming. IM me i would like to have a chat with yaa about that .. I know u r best sixteen now .. But this might be what u do on your existence .. And i know u have lots to ask .. So i can be ready for yaa
?
2012-09-11 18:48:25 UTC
I ran it in Linux, and it printed this:



File "thing.py", line 8

print "Get it?"

^

IndentationError: expected an indented block





In other words, it didn't work.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...