Quiz #1
Quiz 1 will be held in-class in NVIDIA auditorium on Monday, July 11th, from 9:45am - 10:45am. You should plan on being present in lecture for the quiz. If you are an SCPD / remote student, you should receive another email with quiz details.
- The quiz will cover Bit problems and Image problems. You may need to use
if
/else
statements, as well.- The quiz will have three programming problems
- Although we will not take off points for syntax errors, we do expect that your code will be proper Python code. If we cannot determine what you meant by your answer, you will not receive full credit.
- The quiz is closed book, closed notes. You will not be permitted to look at any other material besides the quiz itself.
- By taking the quiz, you are implicitly agreeing to follow the Stanford Honor Code, and if we detect any violations of the Stanford Honor Code during the quiz, you will receive a 0 on the quiz, and we will forward a report to the Stanford Office of Community Standards for further penalties.
- Bring the following to class:
- A laptop with web access. If you do not have access to a laptop, please reach out to Chris and Tori to make other arrangements.
- We will have a limited supply of power outlets if your computer will not last through the entire quiz.
- A mask. We will not let anyone take the in-person quiz without a mask.
- Scrap paper and a pen/pencil. The paper must be blank when you start the quiz.
- A laptop with web access. If you do not have access to a laptop, please reach out to Chris and Tori to make other arrangements.
- The quiz will be delievered on a web page. You can find an example quiz here: Practice Quiz.
- For the practice quiz, we have set the timer to be 100x what you will get during the real quiz, so you can go back and look at your answers for more practice.
- Here are the practice quiz solutions, and here is a PyCharm project where you can test your solutions to see if they are correct.
-
During the quiz, you will not be allowed to leave the quiz website page. The web page logs all attempts to leave the page. If you accidentally leave the page during the quiz, let us know immediately.
- After you finish each problem, you should press one of the "submit" buttons. This will submit all the code for all your problems. We will grade your last submission.
We will give you the following reference information for Bit and SimpleImage on the quiz:
Bit functions:
bit.move()
moves Bit one position forward. Bit cannot go past the outside of its world, nor can it move through the walls, which are black. Any attempts to move outside of the world or into walls causes an error. Bit's eyes always face in the direction Bit will travel in, if it receives abit.move()
call.bit.right()
turns Bit clockwise 90º. Bit can turn anywhere in the world.bit.left()
turns Bit counterclockwise 90º.bit.paint(color)
, where color is either'red'
,'blue'
, or'green'
, paints Bit's current location that color. Any other color strings cause an error.bit.front_clear()
returnstrue
if bit can move forward (i.e. it is not blocked by a wall or the edge of the world), andfalse
if Bit is blocked in the direction it is facing.bit.left_clear()
returnstrue
if there is not a wall or the edge of the world to Bit's left, andfalse
if there is a wall or edge of the world to Bit's left. Bit's "left" is actually above its eyes.bit.right_clear()
returnstrue
if there is not a wall or the edge of the world to Bit's right, andfalse
if there is a wall or edge of the world to Bit's right. Bit's "right" is actually below its front foot.
SimpleImage Reference:
image.get_pixel(x, y)
: returns the pixel at location x, y.pixel.red = value
: Changes a pixel's red channel tovalue
, which must be an integer between 0 and 255, inclusive.pixel.green = value
: Changes a pixel's green channel tovalue
, which must be an integer between 0 and 255, inclusive.pixel.blue = value
: Changes a pixel's blue channel tovalue
, which must be an integer between 0 and 255, inclusive.image.width
: The image width, in pixels.image.height
: The image height, in pixels.