February 3rd, 2021
The purpose of the quiz was to help you self assess where you can improve. Every single person in this class has some area of the material where they could use some extra practice. In this document we are going to go over each of the problems in the diagnostic.
Below is a historgram of the results.Key Statistics
You can find your answers on Gradescope. Let Juliette know if you do not have access to Gradescope.
Regrade Requests We try to grade as consistently as possible, but we are human and we might make mistakes. If you feel like one of your problems was misgraded, please file a regrade request on Gradescope before Wednesday February 10th at 2:30pm. Note that this is the only way to have your regrade request considered; in particular, asking your section leader to take a quick look to see whether a problem was misgraded isn't a way of short circuiting this process. We want you to have the credit you deserve, but filing a formal request helps us make sure that your request goes to the right person.
Can I get extra help?
Yes! Come to Nick or Juliette's office hours, post on Ed, and come to LaIR.
How can I check my answers?
With this document you can check your answer. For each problem we include
I wasn’t able to solve many of the problems on the diagnostic. Should I panic?
Absolutely not! It is normal to find these problems hard. If you didn’t do as well as you would have liked you have a two step procedure. Step 1: make sure you know the underlying concepts (for example, using the i variable in a for loop). Then if you know the concepts but you weren’t able to come up with solutions in time the simple solution is practice and review! Many people incorrectly think that they are not good at this. False! We all can code. You just need more experience. Check out the review session.
My answer is different from the provided solution. Is my answer wrong?
Not necessarily. You will learn a lot by looking at the difference between the teaching team solution and your work. Your answer might be great. There are many solutions.
Can I discuss my solution on ed?
Yes! You are free to share your solutions
Bit is in a 1 square tall tunnel facing the right side of the world. Move bit forward zero or more squares until a clear square appears above - a vertical pipe. Move bit straight up the pipe until blocked, painting every other square green, starting with the square where bit notices the pipe.
def quiz1(filename): bit = Bit(filename) while not bit.left_clear(): bit.move() bit.left() while bit.front_clear(): bit.paint('green') bit.move() if bit.front_clear(): bit.move()
Write the code for parts a, b, and c on the right hand side of this page. You can get the points for each part independently of the other parts.
Given an image file and int margin that is 0 or more, create and return a new out image as follows (see diagram below). (a) The out image should be created as blank white image as usual, with space for two columns added at its sides, each with the width “margin”. The left column is blank, the right column is colored purple. The purple color can be made with green = 0, red and blue = 255 as on the homework. (b) Between the columns, there should be a top area the size of the original image which is left blank. (c) Below the blank area should be a copy of the image which is reversed horizontally but unchanged vertically.
In the diagram, each of the 4 areas is shown with a black border to show where the areas are. There are no black borders in the actual output. The boilerplate code is provided to the right, fill in the missing bits of code:
def quizy2(filename, margin): image = SimpleImage(filename) #### Part a Create out #### out = SimpleImage.blank(image.width + margin * 2, image.height * 2) #### Part b Color in column #### for y in range(image.height * 2): for x in range(margin): # right_col pixel_r = out.get_pixel(margin + image.width + x, y) pixel_r.green = 0 #### Part c Copy in reversed ### for y in range(image.height): # loop over original for x in range(image.width): pixel = image.get_pixel(x, y) pixel_out = out.get_pixel(margin + image.width - 1 - x, image.height + y) pixel_out.red = pixel.red pixel_out.green = pixel.green pixel_out.blue = pixel.blue return out
Given a string s. Compute a string with 2 copies of each “alphabetic” char in s. Recall that char.isalpha() tests if a char is alphabetic. Return the computed string with a ‘@’ added at its beginning and end.
So for example: alpha2x(‘ab12x’) returns ‘@aabbxx@’.
def alpha2x(s): result = '@' for i in range(len(s)): if s[i].isalpha(): result = result + s[i] + s[i] result += '@' return result