Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 2 Review Fall 2003: What do the programs do?

Answers? Comments? Questions on Answers? Questions on Comments?

(Back to Fall2003 Midterm Review 2)



a) -3
b) Yes. It looks at every element in the input, whether it's a list or a string.
c) Not sure what you want for this one. It's whether the value in the sound is positive or negative.
d) 99, since range(1,100) only goes to 99.

Spell out (c) a bit more. How do you know if what is positive or negative? Sounds are neither positive nor negative. Mark Guzdial


a. -3
b. Yes because the loop reads the value at each index point and each of the single quotes have one unique index point.
c. ""++....+ or ""–....-
d. 101 if the two double quotes are two characters & 100 if the two double quotes are 1 character.

c) The string represents how many sample values are positive or negative (and zero).

And how does it do that? A representation is not just the meaning – it's how the meaning is represented. Yes, the string represents positive, negative, and zero, by...? Mark Guzdial


Single quotes don't have anything to do with (b). It's all about sequences. And that's a space between the double quotes. Mark Guzdial

what about these?

a. -3
b. yes because that function can count in a list or a string
c. it represents where the amplitude is? (above or below the 0 line)
d. 99... but if you are talking characters, then 298 because each s will have a + or - attached. which answer are you looking for?
It's 99, not 198 (I think you meant – not 298). The key word there is "OR". You get a + OR a -, never both. Mark Guzdial

in the def bar program, what does the line
s=" "
do? I'm really confused about this part.
Make "s" into a string with a single space in it. Mark Guzdial

How do you get -3??
help!
Walk the program Mark Guzdial


count up the A's, count up the B's, and subtract the amount of A's from the B's, #B-#A = y-x=2-5=-3

Here is a hint for problems like this: make a chart of all of the letters in the string and fill in the coordinating x, y, and y-x values at each cycle through the loop. Its the same idea as the x-y charts some people used on the last exam to keep tabs on values in for loops! Brittany Selden



Link to this Page