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

This page removed for FERPA compliance
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Fall 2005 Practice Quiz 2 Questions


On question number 3, what does != mean?
It means not equal to. The oposite of ==. -Student2081

Are any TA's available to hold a quiz review session Wed. night?
I can't, sorry. Student1919

the answer to #6 is c, right?....and the first line should look like this, def removeGreen(picture)...=)
Ya. Why? :) Student1919

what does the getPixel(oil, x+2, y+1) thingy do in REMOVED?
gets the pixel at a specific location of the bigger picture on the right, do you know where it's telling you to go though? Student1919

can anyone please help explain question REMOVED
What specifically do you want to know? Student1919
Question number 2 is a simple copy function that copies the smaller picture into the larger picture. The variables are named so as to obscure what things are to test whether you are able to trace a function. The task is to figure out where in the 5X5 image the 3X3 image is getting copied. Student1594

It's hard to be specific when I haven't a clue. How about what the x and y values are? 2?
The x and y values are variable. They are defined in the 2 for loops. They each range from 1-3 since the range goes from 1-4. Student1594

in the oil image when it asks for x+2 and y+1 is it taking the second from the left on the top row of the 5X% grid? and if so what color would it make it? i'm assuming that the color will be the average of the 3X3 grid? how do you draw that?
x+2 and y+1 are the coordinates on the 5X5 image that you are going to color. You get the color from the x,y coordinate of the 3X3 image. The function is not averaging colors. Where in the function do you think that it is averaging colors? Student1594

does the answer to # 2 look like a 3x3 grid with the top 3 being dark, the mid 3 white, the bottom 3 dark?
The answer to REMOVED is a 5X5 grid as shown. The different colors are black and white. This pattern is REMOVED complicated than you are describing. Student1594

can someone explain how to go about doing number 2? or least point me in some direction.
Try writing down all the variables and what the represent. Then step through the function one line at a time and continue to keep track of how your variables are changing. The names of the variables is irrelevant. If you simply trace the function a line at a time you should be able to better understand what it is doing. Student1594

does it make every other colomn of the 5x5 the average color of the 3x3
It does not average anything. Where do you see in the function a calculation of average? Student1594

why, in number 3, is it 1 and 0?
1 and 0 would not be an answer. The answer is either 1 or it's 0. The expression 1 and 0 would evaluate to 0. That is not the answer. Student1594

where can we find how to do problem 2 in the book?
Problem 2 is about tracing a function. You can find out how to do that in the designing and debugging chapter. Also, recognize that it is taking in two pictures and somehow ending up with one picture. You could infer that there might be some copying going on as in homework 2 and check the chapter dealing with combining pictures. There is no clear and specific answer to this problem in the book. You should trace it line by line keeping track of what all the variables represent. Doing this should lead you to the answer. Student1594

i'm just glad the ta's have abandoned us
The TAs have not abandoned you. We do have our own classes as well and are trying our hardest to help answer questions. Asking questions at the last minute is always a gamble as to whether someone will be available to answer them. In the future, try asking your questions a day in advance. Then you can be REMOVED sure you'll get an answer. Student1594

can anyone else not post to hw3's questions?
Huh? Student1594

can you just post all the prequiz answers?
The answers won't help you if you don't understand what's going on. If you think you have the answer and you would like to verify it, I'd be happy to help. Giving you the answer will give you a false sense of understanding what you are doing when you don't understand it. You can however easily get the answer to numbers 3 and 6 by typing them into JES and 4 and 5 you can easily find the answers in the lecture slides and/or text book. Student1594


argh but what about REMOVED? is it essentially just moving the 3x3 two spaces to the right and one space down and coloring the entire 3x3 gray?
It is copying the 3X3 image onto the 5X5 image at a location that starts two spaces right and one space down. The entire 3X3 does not start out gray, so why would color it all gray in the 5X5 image? Student1594

why would you color the entire 3x3 gray? What are you doing to transform the 3x3 picture? Student1919

are there any students who understand REMOVED and wouldn't mind explaining...since the TA's clearly won't?
It has been explained that you are copying the 3X3 picture onto the 5X5 picture in a certain location. All you need to figure out is what location it is copying it into. Student1594

If riboflavin = getPixel(soybean, x, y) and x & y both = 1, then wouldnt getColor(riboflavin) = gray? (since the 1x1 spot on the 3x3.jpg is gray?)
The 1,1 spot is supposed to be black. But if you're interpretting it as gray, then yes, you are correct, getColor(riboflavin) would be gray. Student1594

Are you referring to the (1,1) spot on the 3x3 or on the target 5x5?
Riboflavin is a pixel from the soybean image which is the 3X3 image. benzoate is a pixel from oil which is the 5X5 image. Student1594

Is the exact image of the 3x3 copied onto the 5x5, but just 2 spots to the right and 1 spot down?
Yes. Student1594

what is the first thing we are suppose to look at in REMOVED?
You are supposed to start with line 1, and determine which image soybean and oil are referrencing. From there you go to line 2, and figure out which range x goes over. It starts at 1, and goes until the width of soybean, which is one of the pictures. You've determined which picture it is from line 1. Then line 3, you determine the range of the y loop. Then line 4, you get the pixel from soybean at x and y which are the first values that x and y are assigned to in each loop. Then benzoate is the pixel from oil gotten at the location referrenced by x+2,y+1. If you know what x and y are, you can figure out what x+2 and y+1 are. You get the color from the pixel you've determined is represented by riboflavin. They you assignm this color to the pixel represented by the variable benzoate. Then you loop back and readjust your x and y values based on the for loops and continue until you've ran through both loops. When you are done with this, you will see the final result. Student1594

The answer posted on this page to #6 is incorrect. Above, you say the answer is 'C', however I ran the function and the answer is 'A'. Thought people might need this clarification for the quiz.
The answer is C when I run the function. Are you sure you ran it correctly? Student1594

Ok I think I might have it. So- basically, you're replacing a 3x3 in the 5x5. But you have to figure out which one. I think it's the "middle-right" one (starting at 3,2 in the left top corner and ending at 5,4 in the bottom right corner (those are x,y coordinates)). You replace that entire block with the original 3x3. So your picture has the top row gray, bottom row gray, middle column gray, right column gray, and left middle two spaces gray. That's probably completely wrong... so don't listen to me unless the TA's say it's right!





ok, is this what the resultant image should look like for REMOVED.
bbbbb
wwbwb
bbbwb
wwbwb
bbbbb

if so, then this makes a lot of sense, all this function does is paint the soybean image onto the oil image at the coordinates given, x+2 y+1

That would be correct Student1594

is # 3 basically a true false question where 1 is true and 0 is false?

The answer is either 1 or 0 representing what the statement evaluates to. Student1594

i just want to make sure that the answer to #4 is blue

For #6, I typed it into Jes and got answer A too...?
You must be typing something wrong. What does your code look like and what are you typing into JES? I've had someone run it on both the Mac and Windows version. Both give answer C. Student1594

and the answer to #5 is "what will the code look like when i am done"
According to the book: "You start out be developing a list of requirements: What needs to be done, in English or math that can be iteratively defined" Student1594

i'm confused about number 2, please explain...
Read answers to other people's questions. If you have any specific questions that have not been answered, let me know. We've already given a general idea of what to do. Student1594



why is the answer to question 6, C?

You are trying to call removeGreen(picture) but if you look at the function definition, it says def removeGreen(). Notice that there are no parameters in the function definition. Therefore, you are trying to call the function with a parameter when it is expecting no parameters. Any parameter you tried to send into this function would be a parameter of an invalid type since the function takes in no parameters. Student1594

REMOVED is really pretty simple, it just looks scary. Basically, you're looking at all of the coordinates-x's and y's (pixels) in the 3x3 (soybean, a, whatever). You know what because for x in range (1, getWidth (soybean) + 1) tells you the range starts with 1 and goes to (3+1)=4. But that really means 1-3. Remember that whole weird skipping thing. So that same thing happens with the y's. Now, let's move down to setColor (benzoate, yellow5). benzoate isn't a coordinate like x or y, it's saying we're looking AT benzoate. In other examples, it usually looks like this when we use a picture: setColor(picture, blah blah blah) and that tells you to look at the picture. Same thing here. So look at what's going on with benzoate. We're getting the pixels of "oil" or b or the 5x5 but WHICH pixels are we getting? That's the question. x+2 means think about which number we're on (from 1-3 in the range) and plug it in! Let's say we're on our first loop, with X=1. Plug that in and you get 1+2=3. So our x coordinate pixel is 3 for the 5x5. Now for the y, same thing. We're on 1 since the y range also goes from 1-3 so you plug that in and get 1+1=2 for your y coordinate pixel. You have to remember that since the for x in range...is indented further to the left than for y in range..., you have to keep going with all of the x's before moving on the the next y. What I'm saying is, your coordinates will be (3,2), like we just found, then (3,3) and (3,4). You get that by plugging in 1 for x and 1,2,3 for y, respectively. And actually, we change those colors now since we're still in the y-loop. So those coordinates in the 5x5 get changed to what it is in the 3x3. We know this because it says setColor(benzoate, YELLOW5). Look at the yellow5, that's the important part. It tells you to get color from the riboflavin. Ok, so the riboflavin is telling us to look at the entire 3x3 just like it is, pixel by pixel, or x by y. So we "look" or change those coordinates to what the coordinates are in the 3x3. NOW you can move on to the next y, 2. So you'll get (4,2), (4,3), (4,4). Then you go on and change those colors to the ones in the 3x3...etc, etc. Gosh I hope that helps someone...

def removeGreen():
for p in getPixels(picture):
setGreen(p, 0)

>f=pickAFile()
picture=makePicture(f)
removeGreen(picture)
A local or global name could not be found. You need to define the function or variable before you try to use it in any way.

I understand why it should be C, I just don't see what I'm doing wrong in JES...
I'd have to see it working. Are you being careful to pick a picture file when you do pickAFile? If you picked a file that wasn't a picture file, you would get this error on the picture = line. Student1594

How do you get it to stay with indentions? I forgot!
REMOVED the FAQ. Student1594

setColor takes in a pixel, not a picture. Also your description of the loops is backwards. You go through the REMOVED indented loop first, so you go through all the y's before moving to the next x. The result in this instance will be the same reguardless, but it is not always. Otherwise, your explaination is correct. Student1594

for question 3, what does jes exactly do when we type, (5<10 or 3>8) and (1 !=3)in the command area? How would we know that jes would give us 1 as its output?
It compares 5<10 and says true or 1. Then it compares 3>8 and says false or 0. It will then compare the 1 or 0 from those two expressions and give 1 since 1 or 0 is 1. Then it will compare 1!=3 and that's true since 1 isn't equal to 3. So then it will compare 1 and 1 and give you 1. Student1594


def removeGreen():
    for p in getPixels(picture):
        setGreen(p, 0)

>>> f=pickAFile()
>>> picture=makePicture(f)
>>> removeGreen(picture)
A local or global name could not be found. You need to define the function or variable before you try to use it in any way.
>>> 


does that work?

I meant to say you would go on with all the y's before moving on to the x's...my b! :)

I definitely chose a picture file...
Also, make sure you load and save your file before you try running it. If you do not load it, it will not know what removeGreen is and will give you the local or global variable name error. The question specifies that the function is loaded before it is run. This might be why you are getting the wrong error. Student1594



that's what I did wrong! Thanks :)

where in the book can we find REMOVED info about question 3 or in which lecture slide?
so if we had 6>8 or 8>10 and 5=5, jes would give us 1 or 1, which is what? is it 1? are there a set of rules?
Without parentheses, and and or are evaluated left to right with the same level of importance like plus and minus. To clear confusion, the practice quiz uses parenthese to specify. 6>8 or 8>10 would give 0 since both are false and 0 or 0 is 0. Then 5==5 would give 1 and 0 and 1 would give 0. There isn't anywhere in the book that covers this specifically. Try typing things into JES and seeing what it gives if you want to test yourself. Student1594
Also notice I used == and not just =. = is not a boolean operator and so does not evalute to 1 or 0. Student1594

how different will tomorrow's quiz be from the pre-quiz. Is there anything else that we should familiarize ourselves with that isn't on this prequiz, so that there won't be any surprises tomorrow? Thanks
Tomorrow's quiz will be very similar to the pre-quiz in concepts and ideas. The questions will be different. Compare quiz 1 and prequiz 1 for an idea of the similarity level. Student1594

For question REMOVED, if we are sitting the 3x3 on the bottom right corner of 5x5, why is pixel (3,4) white?

Because you are not sitting the 3X3 in the bottom right corner. Student1594

why the eff are people so confused about question # 2? its annoying me, and im not a TA

Some people find some things REMOVED difficult than other people. Please be constructive with your posts. No one is being helped by others telling them that what they find hard is easy to you. Student1594



Link to this Page