Comments for Week of Sept 29, 2003
So, what do you think so-far?
(I guess if you've dropped, you're probably not reading this, so we can't really ask you why you dropped...)
- How's the take-home exam?
- How did everyone feel about their HW2's?
- Is the text stuff making sense?
Comments, Questions, Concerns...
I felt very good about my take home exam, I realized that I actually learned something from homework 2 Charisse Janel Miller
The take home exam was pretty easy... it taught me how to mirror though, thank goodness!
I don't think I really understood the mirroring program until I used it on the exam - I just copied it before, didn't really look at it.
Questions from Monday
Colin Potts passed on some of your questions from Monday, which I'll answer here.
(1) In the first section, a student asked whether there were ways of changing the colors of text and lines/rectangle outlines analogous to rectangle fill colors.
| Absolutely, but the functions we provide you for easy access to the graphics via JES are too simple to handle that. Later on, when we get to full-fledged objects in a few weeks, we'll see how to do the rest. Mark Guzdial |
(2) I stopped mid-sentence in the second section having gone through the yellow square/this-is-not-a-picture example and berated them for not finding the error. Either the arguments to the rectangle drawing calls are wrong or the slide explaining the rectangle functions is wrong. According to the slide, the 4th and 5th arguments are width and height offsets (unlike the x2, y2 arguments, which are absolute coordinates). This means that the 4th and 5th arguments of the rectangle calls should be the same as each other (because they are both square). I told them that one of them had to be wrong (but didn't know which).
| I'm not seeing the bug – I'm sorry! addRect(picture, startX, startY, width, height) is right. Mark Guzdial |
(3) I also got a nice question from the same student in the first section about how you could write a program that changed or analyzed another program. I said that all would be revealed when you got to text processing, but it was a good opportunity for a story about the world is supported by a gigantic turtle, which, of course, is on the back of another turtle, etc. (JES, I reminded them, is just another program that takes files – including their programs – and does stuff with them, and that it is implemented in Java, the environment for which is just another program.... etc.)
| Absolutely! In fact, we're going to be doing that in the next lecture, on Files. We're going to open a .py file AS A STRING, change the string, then write out a NEW program. Thus, we have a program modifying another program. Mark Guzdial |
Thanks, Colin, for taking the class for me!
On the question of color rectangles, could you just draw a solid white rectangle one pixel smaller around a solid colored one, but inside of it? It should create the image of a colored hollow one, yes? Jeff Baker
| Great idea! We'll be able to do things like that in just a few weeks. Mark Guzdial |
For the 1 pm class
I did finish the phonebook example. Here's the code:
def phonebook():
return """
Mary:893-0234:Realtor:
Fred:897-2033:Boulder crusher:
Barney:234-2342:Professional bowler:"""
def phones():
phones = phonebook()
phonelist = phones.split('\n')
newphonelist = []
for list in phonelist:
newphonelist = newphonelist + [list.split(":")]
return newphonelist
def findPhone(person):
for people in phones():
if people[0] == person:
print "Phone number for",person,"is",people[1]
And here's what it looks like running it from the Command Area:
>>> print phonebook()
Mary:893-0234:Realtor:
Fred:897-2033:Boulder crusher:
Barney:234-2342:Professional bowler:
>>> print phones()
[[''], ['Mary', '893-0234', 'Realtor', ''], ['Fred', '897-2033', 'Boulder crusher', ''], ['Barney', '234-2342', 'Professional bowler', '']]
>>> findPhone('Fred')
Phone number for Fred is 897-2033
The slides on the Syllabus page have been updated. 3 pm group will see this in just a few minutes... Mark Guzdial
Link to this Page