Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Summer 2006 Final Review

Summer 2006 - Final Exam Review

This review is harder than the final


Anything denoted with a "hmm" is significantly harder. If you can solve those, then you know you're in good shape.


Conceptual Questions about Jython You Really Ought to Know


Concept Question Page Summer 2006

If you forget everything else we taught you, you should at least know...


Basic Concept Question Page Summer 2006

Pixel iterating


Summer 2006- Questions on Pixel Iterating

Flipping


Summer 2006- Questions on Mirroring/Flipping

Movies


Summer 2006- Questions on Movies

HTML

How many errors are on this?

<html>

<head>
<h1>My webpage</h1>
</head>

<body>
<title>Welcome</title>

<image src=me.jpg>

<p>This is my first paragraph
<p>This is my second paragraph

Thank you for visiting

<a href="helpMe@html.com">Send me comments!</a>

</html>
How would you fix this?

Summer 2006- Questions on HTML

import os Magic



>>> yeehaw(r"C:\documents and settings\Blake O'Hare\Desktop")
Pictures: 2
Text Documents: 9375390
Python Files: 20035



Summer 2006- Questions on import os

Website Snatching

<html>

<head>
<title>The News</title>
</head>

<body>

<h1>Today's Headlines</h2>

<ul>
<li>Scientists link donuts with obesity.</li>
<li>GT students are the happiest according to Princeton Review.</li>
<li>Microsoft goes open source.</li>
</ul>

</body>
</html>

Suppose this page could be found at http://www.blake.com/news.html. Write a function that goes to this page and returns a list of all the headlines.

Summer 2006- Questions on Website Parsing

Manipulating a Sound


Summer 2006- Questions on Sound

Recursion

Using recursion, write a function that...

Summer 2006- Questions on Recursion

Tool for the TA's


Let's imagine that you are a CS1315 TA and you are sorting completed quizzes by the students' recitations. Several quiz-takers did not write their recitation time next to their gtg numbers. Fortunately, you have a file named students.txt in your JES directory. The format of the file is pound sign, gtgnum, backslash, student name, backslash, TA names, backslash, recitation day, backslash, and recitation time. (You may assume that gtg numbers, names, and times won't have backslashes in them.) An exert from the file might look like this:

#gtg123a/George P. Burdell/Brittany, Bobby/Wednesday/6:00-7:30
#gte444q/Howard T. Duck/Swati, Blake/Wednesday/4:00-6:30
#gtg563b/Mickey M. Mouse/Brittany, Bobby/Wednesday/6:00-7:30


Write a function called recitation that will take a gtgnum in a string as input. If that gtgnum is found in the contacts file, print the recitation day and time of the student. If it is not found, print "Not Found." So, if you executed breakout("gte444q") for the above file, you would get printed out "Wednesday/1:30-3:00"

You may want to use these programs from lecture as reference.
def findSequence(seq):
  sequencesFile = getMediaPath("parasites.txt")
  file = open(sequencesFile,"rt")
  sequences = file.read()
  file.close()
  # Find the sequence
  seqloc = sequences.find(seq)
  #print "Found at:",seqloc
  if seqloc != -1:
    # Now, find the ">" with the name of the sequence
    nameloc = sequences.rfind(">",0,seqloc)
    #print "Name at:",nameloc
    endline = sequences.find("\n",nameloc)
    print "Found in ",sequences[nameloc:endline]
  if seqloc == -1:
    print "Not found"

def findTemperature():
  weatherFile = getMediaPath("AtlantaWeather1.html")
  file = open(weatherFile,"rt")
  weather = file.read()
  file.close()
  # Find the Temperature
  humloc = weather.find("Humidity")
  if humloc != -1:
    # Now, find the "," where the temp starts
    temploc = weather.rfind(",",0,humloc)
    endline = weather.find("<",temploc)
    print "Current temperature:",weather[temploc+1:endline]
  if humloc == -1:
    print "They must have changed the page format -- can't find the temp"



Questions, comments, and answers for Final Exam Review Summer 2006: Tools for the TA's

Applying your knowledge


(I) Your mother shows you this cool new image processing program she bought. "I can finally get rid of red-eye!" When she clicks the red-eye removal button, she:
She says, "How did that work? That's amazing. How can the computer figure out what part is red?" Answer your mother's questions, (i) How did the red get replaced by the selected color? and (b) how did the computer know what part was red?


(II) You have a new computer that seems to connect to the Internet, but when you try to go to http://www.cnn.com you get a "Not Found" error. You call tech support, and they tell you to try to go to http://64.236.24.20 That works.
Now both you and the Tech know what's wrong with your computer's settings. What isn't working properly since you can get to a site via the Internet but can't get the domain name www.cnn.com to be recognized?


(III) Your father calls you. "My tech support people are saying that the company website is down because the database program is broken. What does the database have to do with our company website?"
You explain to him how databases can be integral to running large websites. Explain both (a) how the website comes to be authored through the database and (b) how the HTML is actually created.


Questions, comments, and answers for Final Exam Review Summer 2006: Applying your Knowledge

Random Weather Comments

You're thinking about adding something to your HTML home page generator that will make random, relevant comments about the weather depending on the temperature.

Write a function named weathercomment that will take a temperature as input and return one of the phrases randomly. In other words, you want to use the temperature to decide which are the relevant phrases, then pick one randomly from there.

You might recall these programs from class and exam review as examples. The top one generates gendered sentences, and the bottom one uses return to return a sentence to be inserted into a homepage.
import random
def sentence(x):
  nounsM = ["Mark", "Adam", "Larry", "Jose", "Matt", "Jim"]
  nounsF = ["Angela", "Laura", "Meghan", "Mary"]
  verbs = ["runs", "skips", "sings", "leaps", "jumps", "climbs", "argues", "giggles"]
  phrases = ["in a tree", "over a log", "very loudly", "around the bush", "while reading the Technique"]
  phrases = phrases + ["very badly", "while skipping","instead of grading", "while typing on the CoWeb."]
  if x =="M":
    print random.choice(nounsM), random.choice(verbs), random.choice(phrases)
  if x=="F":
    print random.choice(nounsF), random.choice(verbs), random.choice(phrases)

import random

def sentence():
  nouns = ["Mark", "Adam", "Angela", "Larry", "Jose", "Matt", "Jim"]
  verbs = ["runs", "skips", "sings", "leaps", "jumps", "climbs", "argues", "giggles"]
  phrases = ["in a tree", "over a log", "very loudly", "around the bush", "while reading the Technique"]
  phrases = phrases + ["very badly", "while skipping","instead of grading", "while typing on the CoWeb."]
  #print random.choice(nouns), random.choice(verbs), random.choice(phrases),"."
  return random.choice(nouns)+" "+random.choice(verbs)+" "+random.choice(phrases)+"."



Questions, comments, and answers forFinal Exam Review Summer 2006: Random Weather Comments


Questions on Objects


  1. What's the difference between an instance and a class?
  2. How are functions and methods different?
  3. How is object-oriented programming different from procedural programming and functional programming?
  4. What is Polymorphism?
  5. What is Encapsulation?
  6. What is Aggregation?
  7. How did biological cells influence the development of the ideas of objects?

Questions, comments, and answers for Final Exam Review Summer 2006: Questions on Objects





Recursion


Remember this example:
>>> downUp("Hello")
Hello
ello
llo
lo
o
lo
llo
ello
Hello


Here's the code that we wrote that did it:
def downUp(word):
if len(word)==1:
print word #Print #1
return
print word #Print #2
downUp(word[1:])
print word #Print #3


a. Which print statement prints the ever-shortening ("on the
way
down") words? Which print statement prints the single letter in
the
middle? Which print statement prints the longer-growing words?
b. At
most, how many copies of downUp are running at once with the
input
"Hello"?
c. How would you modify downUp to create upDown that
works like
this:
>>> upDown("Hello")
Hello
Hell
Hel
He
H
He
Hel
Hell
Hello



Questions, comments, and answers for Final Exam Review Summer 2006: Recursion

Crossword


Solve the crossword:
External Image

Across:
1. The property of methods that they can apply to more than one object.
2. A computational structure that has both data and behavior.
6. A property of objects that each holds its own data and behavior, that we can't reach inside another object.
9. What we call a function calling itself.
12. A specific function that takes a function as input and a list; it applies the function to each item of the list and returns just those items for which the input function returns true.

Down
1. An agreement for how two computers will interact; examples are HTTP and FTP.
4. A biological entity that scales well and is robust; a model for objects.
5. A network of networks based on a set of agreements.
7. A common language for database creation and manipulation.
8. A word that describes how objects can be combined (objects within objects) to create more complex structures.
10. A property of functions that are well-defined in such a way that the function does one and only one goal.
11. The address of something on the Web (abbreviation); Consists of a protocol, a server domain name, and the path to the page, image, or other object.


Questions, comments, and answers forFinal Exam Review Summer 2006: Crossword





Questions on Databases




  1. Name some characteristics of well-designed relational databases.
  2. What is SQL?
  3. What is a join?

Questions, comments, and answers for Final Exam Review Summer 2006: Questions on Databases





Questions on Functions






  1. Identify three reasons why someone should use multiple functions
    rather
    than one big function in their programs.

  2. What is procedural abstraction?

  3. What is good modularity?



Questions, comments, and
answers for Final Exam Review Summer 2006: Questions on Functions

Name that algorithm!


a. Consider these two programs.
def half(filename):
  source = makeSound(filename)
  target = makeSound(filename)

  sourceIndex = 1
  for targetIndex in range(1, getLength( target)+1):
    setSampleValueAt( target, targetIndex, 
    getSampleValueAt( source,
    int(sourceIndex)))
    sourceIndex = sourceIndex + 0.5

  play(target)
  return target




and

def copyBarbsFaceLarger():
  # Set up the source and target pictures
  barbf=getMediaPath("barbara.jpg")
  barb = makePicture(barbf)
  canvasf = getMediaPath("7inX95in.jpg")
  canvas = makePicture(canvasf)
  # Now, do the actual copying
  sourceX = 45
  for targetX in range(100,100+((200-45)*2)):
    sourceY = 25
    for targetY in range(100,100+((200-25)*2)):
      color = getColor(
    getPixel(barb,int(sourceX),int(sourceY)))
      setColor(getPixel(canvas,targetX,targetY), color)
      sourceY = sourceY + 0.5
    sourceX = sourceX + 0.5
  show(barb)
  show(canvas)
  return canvas


What algorithm is being implemented in these two examples? Explain
the algorithm in English.

B. Consider these two programs:

def findInSortedList(something, alist):
  for item in alist:
    if item == something:
      return "Found it!"
  return "Not found"


and

def turnRed():
  brown = makeColor(57,16,8)
  file = r"C:\Documents and Settings\Mark Guzdial\My Documents\\mediasources\barbara.jpg"
  picture=makePicture(file)
  for px in getPixels(picture):
    color = getColor(px)
    if distance(color,brown)<100.0:
      redness=getRed(px)1.5
      setRed(px,redness)
  show(picture)
  return(picture)


What algorithm is being implemented in these two examples? Explain
the algorithm in English.


Questions, comments, and answers for Final Exam Review Summer 2006: Name that Algorithm!






Questions on Complexity






  1. Who's Alan Turing and what did he do of interest to us?

  2. Is optimization (e.g., the ``song'' problem) class P or
    intractable?
    What does intractable mean?

  3. Is the Traveling Salesman problem impossible to solve
    in
    reasonable amounts of time?

  4. What is a binary search? How do linear and binary searches
    differ? In
    "Big-O" terms?



Questions, comments, and answers for Final Exam Review Summer 2006: Questions on Complexity

JavaScript


Recall this program from the JavaScript lecture:
<html>
<head>
<title>The Simplest Possible Web Page</title>
<script>
function countToTen()
{
   document.write("<ul>");
   for (i=1; i<= 10; i++)
   {
      document.write("<li>Item number: ",i);
   }
   document.write("</ul>");
}

</script>
</head>
<body>
<h1>A Simple Heading</h1>
<p>This is a very simple web page.</p>
<p><image src="mediasources/barbara.jpg" />

</p>
<script> countToTen() </script>
</body>
</html>


Modify it to create a list of 100 entries just like this, starting at
100 and counting down to 1.

Questions, comments, and answers for Final Exam Review Summer 2006: JavaScript


Data structures


For each of the below data structures, define what it is, and write a small example that one can execute in a command area that uses that data structure.


Questions, comments, and answers forFinal Exam Review Summer 2006: Data structures


Compilers, interpreters, and languages, oh my!


  1. If you had a program written in C and you ran it through a C compiler, what would you expect to get out?
  2. If you had a program written in Java and you ran it through a Java compiler, what would you expect to get out?
  3. Why in the world would anyone want to use a virtual machine interpreter, and what does that have to do with programmable toaster ovens and cell phones?
  4. What's a scripting language?
  5. What is machine language? How does it differ from assembler language?
  6. What does it mean for a language to be "interpreted"?
  7. Why is that executing the same thing in JES and Photoshop is always faster in Photoshop?

Questions, comments, and answers for Final Exam Review Summer 2006: Compilers, interpreters, and languages, oh my!







Link to this Page