Professional Documents
Culture Documents
edx 101 cs answres
edx 101 cs answres
Q1
1/1 point (graded)
Change the "print" code below so it produces the following output when
run:
1 2 hello
Q2
1/1 point (graded)
Change the "print" code below so it produces the following output when
run:
1
12
123
print(1)
print(1,2)
print(1,2,3)
Q1
1/1 point (graded)
Change just one line of the code below so it produces the following output
when run.
xyz123
xyz123 xyz123
xyz123 xyz123 xyz123
print("xyz123")
print("xyz123","xyz123")
print("xyz123","xyz123","xyz123")
Q1
1/1 point (graded)
How many colors can a single pixel show at one time?
correct
1
Q2
1/1 point (graded)
In the RGB scheme, what are the RGB numbers to make pure white?
Please type in the red, green, and blue numbers separated by spaces like
this: 100 126 255
Q3
1/1 point (graded)
What are the RGB numbers to make bright yellow? (Please type in the red,
green, and blue numbers separated by spaces like this: 100 126 255)
255 255 0
Q1
1/1 point (graded)
Write code to set the pixel at (0, 0) to blue (i.e. blue value is 255, red and green
are left at 0).
image.setZoom(20);
pixel.setRed(0);
pixel.setGreen(0);
pixel.setBlue(255);
print(image);
Q2
1/1 point (graded)
Write code to set the pixel at (0, 0) to be violet (i.e. red and blue both 255,
green left at 0).
image.setZoom(20);
pixel.setRed(255);
pixel.setGreen(0);
pixel.setBlue(255);
print(image);
Q3
1/1 point (graded)
Write code to set the pixel at (1, 0) to be red.
image.setZoom(20);
pixel = image.getPixel(1, 0);
pixel.setRed(255);
pixel.setGreen(0);
pixel.setBlue(0);
print(image);
Week 2:
Q1
1/1 point (graded)
Add code inside the loop to modify flowers.jpg like this: set each pixel to
have green of 0, leaving the red and blue values unchanged. The result
should be that the flowers look red, since the yellow was made of
red+green light.
Q1
1/1 point (graded)
pixel.setRed(pixel.getRed()*10);
pixel.setGreen(pixel.getGreen()*5);
pixel.setBlue(pixel.getBlue()*20);
print(image);
Q2
1/1 point (graded)
Write code to fix the 51020-stop-sky.png image which should show a red
stop sign front with a background of a light blue sky and green tree
leaves.
print(image);
Q3
1/1 point (graded)
Write code to fix the 51020-oranges.png image which should show a box of
oranges. The box itself is dull gray. The sign on the box is black, with "organic"
written in light orange, and the rest of the letters in white.
image = new SimpleImage("51020-oranges.png");
print(image);
Q1 Iron Puzzle
1/1 point (graded)
Write code to fix the puzzle-iron.png image. The red and green values in the
image are random noise, so they should be set to 0. The real image is in the
blue values, which have been divide by 10. The "solution" image will look blue,
since it is exclusively in the blue values, so don't worry about that. We'll see a
way to fix that blueness in a later section.
image = new SimpleImage("puzzle-iron.png");
print(image);
Q2 Copper Puzzle
1/1 point (graded)
Write code to fix the puzzle-copper.png image. The red values in the image are
random noise, so they should be set to 0. The real image is in the blue and
green values, which have been divide by 10.
image = new SimpleImage("puzzle-copper.png");
print(image);
Q1
1/1 point (graded)
The image below, golden-gate-red.jpg, shows the golden gate bridge, but all of
the data is in the red values.
Write code that for each pixel copies the red value over to be the green and blue
value. The result will be to change the image to grayscale which will look better.
image = new SimpleImage("golden-gate-red.jpg");
}
print(image);
Q2
1/1 point (graded)
Here is the banana.jpg image:
week 3
Q1
1/1 point (graded)
Write code that picks out the pixels of the green leaves in the image (using the
> avg * factor technique, as in lecture). For each green pixel identified, set its
green value to 0. The result is that the green leaves are changed to a sort of
weird purple color, since setting green to 0, we just have red and blue
contributing.
avg=(pixel.getRed()+pixel.getGreen()+
pixel.getBlue())/3;
if(pixel.getGreen()>avg*1.1){
pixel.setGreen(0);
print(image);
Q2
1/1 point (graded)
For the stop.jpg image, write code that picks out the blue sky (using the > avg *
factor technique, as in lecture). Change the blue pixels to be red=20 green=20
blue=20 .. so it looks like nighttime. Adjust your code so it changes the sky, but
not the white letters in the sign (which are technically a little blue).
pixel.getBlue())/3;
if(pixel.getBlue()>avg*1.1){
pixel.setBlue(20);
pixel.setGreen(20);
pixel.setRed(20);
print(image);
Q3
1/1 point (graded)
The goal for this problem is to change the curb to look blue. Detect the red
pixels of the curb using the avg technique. For each pixel, change its red and
green values to be half the average value, and change its blue value to 1.2 times
the average value. In effect, this sets red and green low and blue high, making it
look kind of blue. Note that the blue effect will apply to the reddish plants off to
the right as well -- now they are blueish plants.
avg=(pixel.getRed()+pixel.getGreen()+
pixel.getBlue())/3;
if(pixel.getRed()>avg*1.1){
pixel.setBlue(1.2*avg);
pixel.setGreen(0.5*avg);
pixel.setRed(0.5*avg);
Q1
1/1 point (graded)
Here is the striped-fish-green.jpg image:
Write bluescreen code to place this fish in front of the yosemite.jpg background.
The fish has bits of blue on it, but that's ok since we're using a green
background in this case. Adjust the code so that all of the green towel below the
fish disappears. Little flecks of white will appear in the blue middle section of the
fish; we're stuck with those with our current technique.
Q2(wrong)
0/1 point (graded)
Write bluescreen code to modify the redwood.jpg image, replacing the trunk and
some of the branches of the tree with pixels from pebbles.jpg. The result is a
sort of fanciful looking stone-tree image. Adjust the code so the lower trunk is
changed to pebbles, but not too much of the greenery next to the trunk.
Multiple Choice
1/1 point (graded)
What does Moore's law say?
The number of texts sent by a teenager doubles every 18-24 months.
The number of transistors which can fit on a chip doubles every 18-
24 months.
Hard Drive
RAM
Heat Sink
Which one of the following hardware components is the active "brain" doing
the computation in the computer?
CPU
Hard Drive
RAM
Heat Sink
Which one of the following hardware components provides temporary byte storage during a
computation, but is erased when the power is turned off?
CPU
Hard Drive
RAM
Heat Sink
Q1
1/1 point (graded)
How many different values can be stored in 1 bit? correct
2
Q2
1/1 point (graded)
How many bits are there in one byte? correct
Q3
1/1 point (graded)
One byte can hold a value from 0 up to what maximum value? correct
255
Q1
1/1 point (graded)
4000 kilobytes (KB) is approximately equal to how many megabytes (MB)?
(For all the problems in this section, just type in a number. The unit (MB or
GB or whatever) is always specified in the problem text.) correct
4
Q2
1/1 point (graded)
Suppose you have 10 image files, each taking up 300 KB. About how many
MB of space do they take up overall? correct
Submit
3
Q3
1/1 point (graded)
Suppose you have four 500 MB hard drives plus one 2 GB flash drive. How
many GB of capacity is this overall? correct
Submit
4
Q4
1/1 point (graded)
Suppose we have a video camera that produces video data at the rate of 2
GB per hour. Recording for 15 minutes creates about how many MB of
data? (Note that the answer is in MB) correct
Submit
512
Week 4
Q1
1/1 point (graded)
The CPU in the computer directly "runs" a sequence of what type of
instruction?
Java Code
Machine Code
C++ Code
Javascript Code
correct
Q2
1/1 point (graded)
After a CPU runs an instruction, what does it most often do next?
The instructions for Firefox are translated into Javascript and then run by
the browser.
The operating system copies the instructions for Firefox into RAM and then
the RAM runs the instructions.
The operating system copies the instructions for Firefox from RAM to disk
and then deletes the copy in RAM.
correct
Q1
1/1 point (graded)
Which one of the following best describe what a C++ compiler does?
Someone can run Firefox and note with a stopwatch about how quickly it
can draw different web pages.
Waits for the central ethernet controller to signal that transmission is now
permitted.
Submit
36
Q3
1/1 point (graded)
What is the purpose of a packet checksum?
42.257.99.11
11.250.3.4
45.67.212.100
1.2.3.4
Q2
1/1 point (graded)
Which one of the following is generally not true about routers?
Routers forward each packet one hop closer to its final destination
Q3
1/1 point (graded)
What does ping do?
Notifies the local router that the computer does not want any more packets
Notifies the local router that the computer wants more packets
Q2
1/1 point (graded)
Write code to print the rows for the name "River". In this case, there are two
such rows, but the same basic code pattern as for question 1 works. This shows
how the loop really is just testing every row.
Write code to print the rows where the rank is less than (<) 10, i.e. ranks
1 through 9.