Go back to: General discussion
Here's my source code and output without extra credit:
--- Source Code ---
print "Mary had a little lamb."
print "Its fleece was white as %s." % 'snow'
print "And everywhere that Mary went."
print "." * 10 # that will print '..........'
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"
# if you remove the comma at the end it will print the statements on different lines
print end1 + end2 + end3 + end4 + end5 + end6,
print end7 + end8 + end9 + end10 + end11 + end12
--- Output ---
Its fleece was white as snow.
And everywhere that Mary went.
..........
Cheese Burger
EXTRA CREDIT
The first part was to add comments which I didn't think was neccasary
and the rest was about debugging and I didn't make any mistakes the first time so I didn't do any of it.
but out of interest can some of you guys comment the mistakes
Fairly easy exercise
Here's my source code with commentaries:
# just print the string
print "Mary had a little lamb"
# print the string with the format character %s
print "Its fleece was white as %s." % 'snow'
# just print the string
print "And everywhere that Mary went."
# the "." followed by * 10 will print 10 dots
print "." * 10 # what'd that do?
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"
# watch that comma at the end. try removing it to see what happens
# the comma has the function of printing all the ends on the same line (without the comma the word Burger is printed on another line)
print end1 + end2 + end3 + end4 + end5 + end6,
print end7 + end8 + end9 + end10 + end11 + end12
wow are we in week 7 yet you must be super ahead
Nope, not super ahead. We're supposed to do four exercises each week.
Here's my program...the first time I ran it I had forgotten end5, end9 and end10 in the last two lines. My output looked like Cheee Buer. I am not sure why I missed those...
My question...we used 'end1''end2' etc. to define the letters for the Cheese Burger output. Is there something special about 'end ' ? Or was that just something random the author chose?
print "Mary had a little lamb."
print "Its fleece was white as %s." % 'snow'
print "And everywhere that Mary went."
print "." * 10 # what'd that do?
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"
# watch that comma at the end. try removing it to see what happens
print end1 + end2 + end3 + end4 + end5 + end6,
print end7 + end8 + end9 + end10 + end11 + end12
If you replace 'end ' with whatever you want, you get the same result, so there's nothing special.