Final Review Spring 2009

The final will be closed books and notes. You will be asked to provide short essay answers to questions, to write HTML, CSS, and Python code, and to understand provided samples of code enough to answer questions. The final is cumulative, so one way to study is to make sure you can answer all of the midterm questions correctly.

In studying for this final, you should review all of the notes on the course calendar. Below are sample questions for particular points of interest. You should practice answering questions and writing code with pencil and paper-- writing code on paper is much different than on the computer.

You are encouraged to set-up an appointment with your instructor to go over material and attend the available review sessions.

The following are sample questions-- these exact questions won't be on the test, but they are indicative of the types of questions you'll be asked to answer. The number in parenthesis for each section refers to the approximate percentage of the test devoted to that subject.

Python Programming

You will be asked to code, to specify the output for a given piece of code, and to answer short questions on concepts.

1. Write a program that sums the first n numbers.

2. Write code that computes the total of all the values in a list, e.g., for the list [5,2,9], the program would print 16.

3. Write an interest rate program with complex conditions.

4. Write a program that computes the GPA from a string of grades, or from a list of grades input by the end-user.

5. What is a variable?
How would you describe the Python programming statement  value = value + 1 ? How can a value equal itself plus one?

6. What is a function? A parameter? A formal parameter? An actual parameter.

7. How do you get input from the end-user in a command-line Python program? How do you get input from the end-user in a dynamic web application?

Picture Programming with Python (JES)

For these questions, you'll need to understand how to modify an image-- a matrix of pixels-- with a nested loop. You need not memorize the specifications for the JES functions-- they'll be given to you. But you will need to use them appropriately to write programs and to understand programs given to you.

1. Write a program to turn every other column red

2. Write a program to grayscale a picture

3. Write a program that draws a picture within a picture from the coordinate (100,100) to (300,300), with no chance of an error.


4. Write a program that draws four pictures within a single canvas.

5. Be able to convert hexidecimal (base-16) color specifications into base-10, and vice-a-versa. (this was originally off this list, but it will be on test!)

Programming the Web

1. Write basic HTML for:

    paragraphs, links, images, headings, overall structure (html, head, and body tags).

2. Suppose "example.html" lives in the subdirectory 'site1' off the main root directory of the site mysite.com. What would be the URL to view example.html? If you wanted to put an image 'logo.jpg' in the images subdirectory of site1, how would you display the image within example.html?

3. Explain, in general, how relative URL references work.

4. What is the purpose of cascading style sheets (CSS)? Show how you would use an HTML id and a css file to separate the styling from the content of a page.

5. Why is it a good idea to separate the CSS styling from the HTML pages of a site.

6. Draw a diagram showing what occurs—network communication, processing-- when someone types a URL in a browser. Your diagram should refer to the following terms: browser, server, DNS, CSS, HTML, IP, Domain, URL, Server, HTML template, controller code. You should define these terms enough so that your understanding of them is clear.

7. Consider the following URL:

    facebook.com/friends?id=999777&name=joe

Which part is the domain? What is the request sent to the server? What is the ? and the &?

8. What is an HTML template? How is it different than HTML. What does the controller in a web server do, in general.

9. What is the difference between a static and a dynamic web page? How does an HTML template and controller code allow for dynamic web pages to be served?

10. Explain how an HTML template communicates with server controller code, in both directions. Provide snippets of Python and HTML code to illustrate.


















11. How would you modify the HTML and controller below so that the GPA is calculated and shown.
 <html>
  <body>
    <h2>GPA Calculator</h2>
    

    <h3>Enter a string of grades, e.g, ABCAAB</h3>
    <form action="/on_calculate" method="get">
      Grades:<input type="text" name="grades" value={{grades}}>
   
      <input type="submit" value="Calculate"></div>
    </form>
    Number of Grades: {{gradeCount}}
    GPA: {{gpa}}

  </body>
</html>
 class CalcController(webapp.RequestHandler):
  def get(self):
    grades=self.request.get('grades')
    # calculate something
    count = len(grades)
   # set up the template_values
    template_values= {'grades': grades,'gradeCount':count}
    # render the page using the template engine
    path = os.path.join(os.path.dirname(__file__),'index.html')
    self.response.out.write(template.render(path,template_values))

12. Write an interest rate program for the web.

13. For the GPA (twitter) example, what is the dynamic part of the HTML template? How does the controller 'replace' the dynamic parts with the values it computes?

14. Given an HTML form, such as the ones in the GPA and Twitter examples, what URL is sent to the server when the user clicks on the submit button?

15. Consider the following HTML form and controller:
<html>
  <body>
    Already a member? <a href={{login_url}}  >login</a>
    <br/>
    Register <br/>
      <form action="/register" method="get">
         <input type="text" name="name" value="name">
         <input type="submit" value="Submit">
    </form>
  </body>
</html>

 class RegisterHandler(webapp.RequestHandler):
  def get(self):
    name=self.request.get("name")
    person = Person()
    person.name=name
    person.user=users.get_current_user()
    person.put()
    self.redirect('/home')
How would you modify the form so that both a first and last name could be entered on registration? How would you modify the controller so that it would handle this additional information correctly?
What URL would be sent to the server when the new form is submitted?

16. Google's App Engine allows programmers to create web apps and run them in the cloud. What does this mean? How can such a tool spur innovation from startup companies?


The Internet and Society

1. Discuss the advantages and disadvantages of 'cloud' computing for 1) programmers, 2) ordinary computer users. 3) society in general. What has cloud computing allowed you to do in this class?

2. Describe how Google ranks web pages, including term analysis and page rank.

3. Describe how Google crawls the web. How do blog search engines do things differently?

4. Describe the difference between a formal taxonomy and a folksonomy. What is meant by the term 'user-generated data'?

5. Del.icio.us is to Yahoo's Web Directory as Wikipedia is to Britannica. Explain.

6. How is blogging, folksonomy, and web 2.0 counteracting the conglomeration of media companies?

7. The number of dynamic web pages on the web has increased significantly. What does this mean for someone who wants to build web pages? What skills do they need to learn?

Recent site activity