The first Debriefing will cover the following topics:
Unix
Packaging
Object-Oriented Programming
The Debriefing will consist of definitions, short answers, code evaluation, debugging, and programming questions related to the Project 01.
For the programming section, you will be able to use your computer (but only after you have completed all the other sections).
Below are examples of the type of questions that may be asked on the Debriefing. It is mean to be representative, rather than exhaustive (ie. there may be questions that show up on that are not show below).
Briefly define the following terms:
Unix
Shell
Script
She-bang
Module
Package
Class
Instance
Field
Method
Identify which Unix commands you would use to perform the following tasks:
a. Check to see what files are in the current directory.
b. Find out where you are in the filesystem.
c. Move into another directory.
d. View the contents of a file.
What exactly is git? What does it allow us to do? Explain the commands you would use to save the changes you have made to a project and send them to Bitbucket.
Explain how a single file be both a script and a module. In particular, describe how a file can distinguish between being executed as a script and being loaded as a module.
Describe how you would make a script executable and how a script could access command line arguments passed to it?
What is the result of the each of the following lines of Python code:
color0 = Color() # 1 color1 = Color(1, 2, 3) print color0 # 2 print color1 print color0 == color1 # 3
Additionally, for each of the markers (ie. # 1
, # 2
, # 3
) identify
which protocol method is being called and what happens inside each
one.
What is the result of the each of the following lines of Python code:
point0 = Point() point1 = Point(y=3, x=4) point2 = Point(point0.x + point1.x, point0.y + point1.y) print point0 print point1 print point2
What is the result of the each of the following lines of Python code:
image = Image() print image print image[Point(image.width, 0)] image.width = 100 print image print image[Point(image.width, 0)]
What is the result of the each of the following lines of Python code:
image = Image() point = Point(0, 0) color = Color(1, 2, 3) print image[point].r, image[point].g, image[point].b image[point] = color print image[point].r, image[point].g, image[point].b image[point] = Color(color.b, color.g, color.r) print image[point].r, image[point].g, image[point].b image[point] = Color(g=color.g) print image[point].r, image[point].g, image[point].b
Color
class:class Color(object): def __init__(self, r, g, b): r = int(r) g = int(g) b = int(b) def __eq__(self, other): if self == other: return True def __str__(self): print 'Color(r={},g={},b={})'.format(Color.r, Color.g, Color.b)
Add a new draw_square
method to the Image
class:
def draw_square(self, point, length, color): ''' Draw a square given the upper left corner point and the length of each side with the given color '''
Add a new draw_rectangle_frame
method to the Image
class:
def draw_rectangle_frame(self, point0, point1, length, color): ''' Draw a rectangular frame from point0 to point1 with a border of size length and with the given color '''
Add a new draw_wave
method to the Image
class:
def draw_sinewave(self, point0, point1, amplitude, color): ''' Draw a sinewave from point0 to point1 with the given amplitude and color '''
Write a script draw_circles.py
that takes in three arguments:
$ ./draw_circles.py MIN_RADIUS MAX_RADIUS NCIRCLES
This script should draw NCIRCLES
circles with radii between
MIN_RADIUS
and MAX_RADIUS
and emit the PPM
image.
Write a script draw_house.py
that takes in three arguments:
$ ./draw_house.py HOUSE_COLOR DOOR_COLOR WINDOW_COLOR
This script draws a house with HOUSE_COLOR
that has one door with
DOOR_COLOR
and two windows with WINDOW_COLOR
.