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

Pre Quiz 1 Question Page Spring 2006

Is it safe to say, that if the blue's value is less than 30 from 128, then just multiply the red value by 2?
What do you mean by less than 30? If the VALUE is less than 30...no. It's the DISTANCE that you're looking for. Amanda Bennett

should we study other information for the quiz other than the stuff on the pre-quiz?
if you know everything on the prequiz, you should be fine for the quiz. Amanda Bennett

Another question about #2, first row, third column.

Why does it not change to (2,0,255)? The distance is the square root of 128, which is less than 30, so red doubles, right?
The distance is the square root of 128^2 plus 1^2, which is actually the square root of 16385. Don't forget what the formula is! Amanda Bennett

My distance set-up SQRT( 1 + 127) = about 17.
Should be SQRT(1^2 + 127^2) Amanda Bennett


wher can I print out the practice quiz?


I don't understand why we manipulate our answers in no. 6 by adding/subtracting 256. Why don't we use 255? I read pages 61-62 and they didn't seem too helpful.
Don't forget there is 0 as a value for a color. So, you have the range [0,255] for color values, which means you manipulate things by 256. Amanda Bennett



Is the answer to #6 14,80,255
This is answered below. Check it out Amanda Bennett


is this an in-class quiz?
Yes. Next Tuesday. Check the timeline under the Syllabus link on the main page. -Albert d'Heurle
Moved to Thursday

How do I find out who my TA is - I have the 6-7:30 Thursday Section? Thanks!
Click this link TA-Student Pairings - Albert d'Heurle

is the answer to question 6) 34,80,255 ?
Close, but no. Liz Helms

is the answer for #6) (14,80,0)?
also close, but not quite. check out you last value... Amanda Bennett

On the quiz for problem 2 do we subtract (0, 0, 128) from all the six in the box to get the new colors of each box?
No, you need to get the distance between the colors in the box and (0,0,128) to see if you need to change the colors. Amanda Bennett

Hey, I had to miss my first resitation on Tuesday cause I had a prior appointment. Resitation is optional, is it not? Cause I'm freakin out that I missed something if it isn't. Thanks alot!
Yes recitation is optional. You might want to go to one on thrusday just to see what it is like. -Albert d'Heurle

I second Albert's suggestion. You might benefit from going to another recitation this week in particular, because the mechanics of downloading JES, using WebWork, etc. are being covered. You need to be comfortable with all of these skills, because you will be using them for all the labs and assignments. – Colin Potts

Is the answer to #6 14,80,255

Yes, it is. -Blake O'Hare

Hey, everyone. I explained in class that weird things happen if you try to set a color value outside the range 0..255, but only hinted what happened. The pre-quiz (and maybe the quiz ... hint, hint ...) requires you to state what happens more exactly. Here's the scoop: It's just like two-digit dates or clocks. Once you get to the maximum, the numbers just wrap around. So just as there was no year 100 after year 99 in the Y2k situation, and just as there is no 13 o'clock on 12-hour clock faces, there is no color intensity value of 256. As with the year (year 00), hours (1 o'clock), so with colors. If you add one to 255, you get zero, not 256. This is explained in pp. 61-62 of the book. Colin Potts

For problem #2, the only color that changes (if it changes at all) is red... is that correct?
yes. Liz Helms

is the answer to question #2
(0,0,128)(2,0,128)(1,0,255)
(4,2,128)(20,10,120)(128,128,128)

Check your answer for the first row, third column. -poof #10
Yes, this is correct.


i don't understand why the first row, third column would change. the distance of the color pixels from (1,0,255) to (0,0,128) is 127. this is not less than 30, so why would the numbers change?

Indeed. Charlie is a silly head! -Blake O'Hare

Wouldn't the answer in the 2nd row and 2nd column be (20,10,128)? Also, why don't all the blue values change to 128, I thought the only thing that depended on if the distance is less than 30 was multiplying the red value by 2.
No. If the blues were to change, that would require a setBlue or setColor in the code, which there is not. Also, double check your distance formula. -Blake O'Hare

so first row, third column is (1,0,255)?
Yes. -Blake O'Hare

this is what i got
(0,0,128) (2,0,128) (1,0,255)
(4,2,128) (20,10,120) (255, 128, 128)
I dont' know if that's right either
It isn't. Make sure you know what the distance function and if statement are really doing. This will be covered a little more on Tuesday. -Blake O'Hare

wouldn't the answer to #6 be (15, 80, 255) because the max pixels is 255, not 256?

Your because clause is correct. Your numbers are not. The best way to think about the wrap-around problem with color values is to add 256, then divide everything by 256 and the remainder is the correct value. -Blake O'Hare

is the answer to question #2
(o,o,128) (2,0,128) (1,0,255)
(4,2,128) (20,10,120) (0,128,128)

No. Read the other questions people ask, and their answers, and sometimes, you wont even have to ask your question. Liz Helms

In question #2, I understand why the first digit is multiplied by two in the first two columns, but why does the first digit in the third column remain the same?
Think about how an if statement works and what it is used for. Larry Olson

Is the answer for question #5 (255,0,0)? Because in the book it illustrates pure red as (255, 30, 30)...I do not understand?
The meaning of each color component, ( red , green, blue ), in a pixel is the amount of that color present in the pixel. Hence, black, (0,0,0) is the absence of all colors and white (255, 255, 255) is the complete presence of all color. Think of a few other colors, perhaps purple which is a mixture of red and blue in various amounts. A shade of purple could be something like (128, 0 , 100). Hope this helps.Larry Olson
Also take a look at the question itself, it kind of hints at the correct answer. Larry Olson

i have no idea how to get the numbers in the boxes. is it saying if any of those numbers are within thirty of them then change the red? or is it saying if the red value is within thirty to change the red? or is it talking about the blue entirely? none of the above questions help.
Laura Consiglio
First things first. The answers that your classmates post on this page may or may not be correct. In general if they are incorrect we will say something. However, if they are correct, we might not make a sound. So dont take all of the answers on this page as the be all end all. Instead, trust your own instincts (note: in the way you posed the question it looks like you DO have a good idea, you ARE on the right track). That being said, consider each part of the program individually. First are variables which are just holding values. For instance, lightBlue is holding the color with rgb values ( 0 , 0 , 128). The next thing to notice is the for loop. Think about what a for loop does. It repeats a section of code over and over again. Finally, think of what an if statement does. It allows you to make a choice. Basically, if "something" is true then do "this". In this case we are checking to see if the color value of a pixel is within a certain distance of another color, specifically light blue. How do we do distance? Well that is nothing more than the forula SQRT( (Red0 - Red1)^2 + (Green0 - Green1)^2 + (Blue0 - Blue1)^2) (NOTE: See page 49 in the book). Pull out a calculator and plug in some numbers a few times. Larry Olson



can someone tell me how to do question #6???



Link to this Page