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

Spring 2006 Final Review

Note: The idea of this review is not to tell you exactly what is going to be on the test but to demonstrate concepts that may appear on the upcoming exam. Although we try to comprise all topics, there is a possibility that other topics covered in class and not on this review will be included on the exam



Please try these questions! Post your answers, questions, comments, and concerns on the pages for each question. Those comments, questions, etc. can also be about each others' answers! If someone posts an answer that you don't understand, ask about it! If you see a question here that you know the answer to, don't keep it to yourself – help your fellow students!

We will be reading your answers. Here are the ground rules for the interaction.

Applying your knowledge



(I) 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?

(II) 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 Spring 2006: Applying Your Knowlegde


Working with Classes


Imagine that you have a class Box like the below:
class Box:
  def __init__(self):
    self.setDefaultColor()
    self.size=10
    self.position=(10,10)
  def setDefaultColor(self):
    self.color = red
  def draw(self,canvas):
    addRectFilled(canvas,self.position[0],self.position[1],self.size,self.size,self.color)



(a) What will you see if you execute the below:
canvas = makeEmptyPicture(400,200)
joe = Box()
joe.draw(canvas)
show(canvas)


(b) Add a method to Box named setColor that takes a color as input, then makes the input color the new color for the box.
(c) Add a method to Box named setSize that takes a number as input, then makes the input number the new size for the box.
(d) Add a method to Box named setPosition that takes a list or tuple as argument, then makes that input the new position for the Box.

Now consider the below code added to the above:
class SadBox(Box):
  def setDefaultColor(self):
    self.color=blue


(e) What will you see if you execute the below:
jane = SadBox()
jane.draw(canvas)
repaint(canvas)

Questions, comments, and answers for Final Exam Review Spring 2006: Working with classes





More coding




Questions, comments, and answers for Final Exam Review Spring 2006: More Coding




Map Filter Cont.


Now that you understand how map and filter work...
Write a function that takes in a picture and increases the red for all the pixels with a red value that is less than 100. Use map and filter. Note this will require 2 helper functions and one main function.

Questions, comments, and answers for Final Exam Review Spring 2006: Map Filter



Handling an address book


Let's imagine that you are keeping track of all of your contacts in a file named contacts.txt in your JES directory. The format of the file is pound sign, name, colon, company, colon, phone number, colon, and key phrases that you want to remember about this contact. (You may assume that names, companies, phone numbers, and key phrases won't have colons in them.) The file might look like this:

#Calvin:Calvin & Hobbes:990-8979:Cartooning, tiger tamer, philosophy
#Luke:Skywalker Ranch:897-7765:Lightsaber battles, martial arts, philosopher
#Arthur:Camelot Inc.:453-8976:Holy grail seeker, sword puller, king

Write a function called contact that will take a keyword in a string as input. If that keyword is found in the contacts file, print the name, company, and phone number of the contact. If it is not found, print "Not Found". So, if you executed contact("king") for the above file, you would get printed out "Arthur:Camelot Inc.:453-8976"

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 Spring 2006: Handling an address book


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 Aggregation?
5. How did biological cells influence the development of the ideas of objects?


Questions, comments, and answers for Final Exam Review Spring 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 Spring 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 for Final Exam Review Spring 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 Spring 2006: Questions on Databases




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 Spring 2006: Questions on Complexity



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 for Final Exam Review Spring 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 Spring 2006: Classes and Objects





What Makes Computers Tick?


1. Give several examples of hardware and what each do and why they are important.
Questions, comments, and answers for Final Exam Review Spring 2006: Hardware?


Pixel iterating


Spring 2006 Final Review - Pixel Iterating





The Internet


Briefly discuss the following...

What is a...

Spring 2006 Final Review - t3h Intarw3b!!!1



Trace Me round 2


Say we have the following code:
def whatAmIdoing():
   show(pic)
   for t in range(0,21):
     pic = makeEmptyPicture(100,100)
     x=50+t*cos(t * 2 * pi / 5)
     y=50+t*sin(t * 2 * pi / 5)
     addRectFilled(pic, x, y, 10, 10, blue)
     repaint(pic)


What motion will the rectangle move in?

TraceMe Questions





Links to this Page