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

Midterm Exam 2 Review Spring 2003: Short Essay

Comments? Concerns? Answers? Questions? Questions about Answers?
Back to Sp2003 Midterm Review 2


For number one on the short essay, would the following be an acceptable answer you think? A task that would need a program would be adding all numbers 1 through 1000 b/c it would be too hard to do by hand or calculator.A task that wouldnt need a program would be adding numbers 1 through 5.
But even going 1 to 1000 wouldn't really require a program, would it? Isn't it just a one-liner? Move up a level of abstraction in your thinking: WHEN do you write a program, and when don't you? We've talked about it in class on drawing complicated graphics and making specific sounds. Give me the general rule for when you need a program, and when you can just use something like Photoshop. Mark Guzdial

is red a bad color for chromakey because there are red components in people's faces?
Yes, but in general, Red is too common a dominant component in a color. Mark Guzdial


Do you want a specific example for 1 or is something like this ok for part of it:
A task that requires a program is one in which many different files or parts (pixels, samples, pieces of text) of files are being processed and manipulated, and although the task may possibly be preformed using an existing program on the computer (ie. Photoshop), the task will be more precisely preformed and easily taught or passed from one person to another by writing a program in JES. A task that would not require a program is one that can be easily calculated, preformed, or taught and does not require complex manipulations.
That's all true, Summer, but the specific rules we gave in class were that you write a program (a) when you want to communicate the PROCESS (how you got to the result) to someone else and (b) when you want the process to be REPLICABLE by others. People do pretty complex things in Photoshop without writing a program. You OUGHT to write a program if you want to communicate the process or help others to replicate it. Mark Guzdial
2. An array is a continuous line of elements that we have used to represent data in the form of sound and text. A matrix is a two-dimensional array, containing both width and height that we have used to represnt pictures. Trees are elements that being with one "root" and "branch" out into different directories which eventually end in "leaves" or files. Each path on the tree leads to a different file.
Very nice! Mark Guzdial
3. Dot notation is used to access certain capabilities of a file (module) that have been imported to a computer and contain additional functions and objects that JES originally did not. It is written as "module"."function"? (I'm not sure about that last part)
Yup. Mark Guzdial
6. A file can be saved in many different directories within a disk (as more folders are created), which would be better represented by multiple paths or branches off of the original disk leading to the file. Summer McWilliams
But why use a tree rather than an array? Why do we have many directories instead of just one? Mark Guzdial

Is this what you're looking for in #1?

We write programs when we want to illustrate the process of the task being completed. That way, others can open up the program both to see what how we accomplished the task and to be able to tweak the program for their own use. Writing a program might be useful when one wants to take a bunch of numerical data and run it through a lengthy series of mathematical operations. So instead of using the existing calculator application to divide x by y, take the integer of the outcome, add five, etcetera, you just write a program that will do the task over and over again in one easy step. If illustrating process and facilitating mimicability isn't important, like for shrinking an image for a website, then photoshop or another existing application are fine alternatives.
Exactly right – different words than I used before, but this is the same idea. Mark Guzdial

Is a "tree" the same as a complete "path" ? example- c:\Documents and settings\Mark Guzdial\My Documents\mediadiasources\640x480.jpg
A complete path describes a journey down the tree from the root. Mark Guzdial

1. We write programs to do complex things that PhotoShop or other pre-packaged programs don't offer. This allows us to better communicate because the restrictions are fewer than when you have to use a pre-packaged program.
Complexity does suggest writing a program, but people do do complex things in Photoshop, so mere complexity won't get people to do something other than applications software. Mark Guzdial
2. Trees begin with a "root" which says which drive, for example C:\ The "branches" are next and say which directories, and the filename is the "leaf". According to the slides, a "path" is a "complete description of what directories to visit to get your file". If that's all that a "path" is, then a path and a tree would not be the same. Trees contain both the root and the leaf.
A path is just a journey through the tree. The question is about tree vs. array vs. matrix. Mark Guzdial
3. Data are objects in Python. Methods are special functions. Dot notation is how methods are executed on objects. Dot notation is written as Object.method()
Objects and modules. Mark Guzdial
5. A function is the objective of what is being done, while a method is the way to tell the computer what to do to the object. A method is a function, but already built-in to Python. However, you cannot just put in a method, you must use dot notation to execute and tell the computer which object and which method to execute.
I didn't get that first sentence. The last sentence is right, but doesn't really explain the difference. Here's a hint: We've just been writing functions in class, right? We used no dot notation. Do you think that writing a method looks much different than writing a function? How so? Mark Guzdial
6 A tree is a better representation because it contains the root(or drive, like C:\, D:\, A:\), branches(directories), and the leaf(filename). An array is just a continuous line of text or numbers. If an array were used, you would have a separate array for EVERY file. With trees, you can group similar things, such as grouping all the Microsoft Office Applications(.exe files) under one directory.
Rebecca Phillips
Rebecca, would you like to have ALL your files (I'll bet you have 5,000 or more files on your hard disk) in ONE directory? Why or why not? If you said no, what's the advantage of having a tree structure on your disk? Mark Guzdial


6. All the files shouldn't be in one directory or you couldn't find stuff very easily. My point was that if you have a tree structure, you can categorize and organize files to make them easily accessible.
Rebecca Phillips

I expanded on one of the earlier answers to #2.

2. An array is a continuous line of elements that we have used to represent data in the form of sound and text. A matrix is a two-dimensional array, containing both width and height that we have used to represent pictures. Trees are elements that begin with one "root"(such as C:\) and then split out into different “branches” called directories, which eventually end in "leaves" or files. Any directory can contain multiple directories and files. We use trees when we want write a program that processes all of the files in a directory, for example when we alter movies. Without trees it would be extremely tedious to alter data like movies since you would have to specify the entire name of every file – the computer couldn’t just know that you want everything in a given directory. We have many different directories so that we can group similar things together to make them easier to locate. For example, if I had only one directory on my computer, I would have to search through every file on the machine to find the one file that I needed.
Lauren Biddle

No, directories don't have anything to do with processing all the files in a movie. But making things easier to locate is the right idea. Mark Guzdial


I'm still having trouble getting a solid difference between functions and methods. I know methods are special functions, but what is the official definition of a function? Anyone have any ideas?

Brittany Selden

Try it that way, Brittany. Use a simple definition of functions like "a recipe that tells the computer how to do something," but then explain how methods are special. Mark Guzdial


So you could say a function is a "a recipe that tells the computer how to do something,". A method is a special function that only objects of the same type understand. Methods are already built into the system, but you have to use dot natation to execute them, telling the computer exactly which object and method to change. That work??? Sarah Edwards


How's this?

6.) A tree is better because files can be kept inside of each other and are easier to sort. With an array, every file would be on the same layer. With a tree, you can branch down and create pathways to sort your data. Sarah Edwards

Nice answer on the functions/methods, Sarah, but files aren't actually inside of other files. Mark Guzdial


another try on #6: With an array, your computer would have to search through every file you have on one directory to find what you are looking to access. This would take forever, especially when you are trying to write programs trying to access certain files. A "tree" system of setting up a disk allows you to have a specific path from the directory into folders and eventually into individual files. This way, the computer can easily (and quickly) access a certain file, and the user can see a specific path to that file, without going through every single file on his directory first. Kelly Farrell

addition: It also allows you to group certain types of files together in folders for easier and more organized access. You could not do this with an array. Kelly Farrell

VERY NICE! Yes, trees allow for faster access under some conditions, and are useful for organizing. Mark Guzdial


Another try on #5. A function is a recipie that tells the computer how to do something. It can be very simple or pretty complex. A method is a type of function. It is already built in to JES. However, you cannot just execute a method. You have to use dot notation- object.method() - to execute and tell the computer which object and which method to execute. Kelly Farrell


Sarah posted an answer for number 5 that he said was right... look up a few paragraphs and compare to that

Kelly, you got it. Methods aren't just built into JES. We'll be defining our own methods in just a few weeks. Mark Guzdial




Link to this Page