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 PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Summer 2006 Homework 4 questions page

Post Questions here:

Can we please get this week's lecture slides posted. Especially the 28th as that seemed to address this homework.

I believe its all on the static webpage. - Bobby Mathew

is H.W 4 still due on July 6th?

Unless its extended in the last minute, its still due on Thursday - Bobby Mathew

Does anyone have a suggestion as to how to get the Height of the picture to show on the page? I tried making the file a picture and then using getHeight, but JES keeps getting mad at me for doing that.

You can use pic = makePicture(file) and then do getHeight(pic) - Bobby Mathew

how do you create these rows and columns correctly...

You can use the
<table>
tag and then use
<tr>
for each row and
<td>
for each column in the row. - Bobby Mathew

I used makePicture(file) and getHeight(pic), but I am unable to get the value of the getHeight function to appear in my HTML. How can I display the height on the page that I create?

Look up the str function. It will be of use to you for this part. -Blake O'Hare

how many media items do we have to use? Is there a minimum? Do we have to use a sound and a picture? or can it be just sounds, just pictures???

hmm.......that isn't specified. For now, I guess you should have a minimum of 4 rows (media items), at least 2 pix and 2 sounds. If there are any changes, I'll post it here and on the announcements page. - Bobby Mathew

Thanks bobby

I got confused on the previous answer. For the previous post, your code should generate the table for the media items in the folder which the TA checks with. So, when I test your code, the table should be formed based on the number of media items in the folder I choose. So, your code should be according to that. Sorry about the confusion. - Bobby Mathew


we should assume if the table function is working there should be the outline of a table correct? Doesnt it make since to add the tags before the paragraph tags and after to make a proper table in our code?
There'll be an outline of a table only if you specify a border (i think). The
<table>
tags shouldn't be in any loop. It should be written to the file only once. - Bobby Mathew

Any idea as to how to count the total number of media items on the page?
Put a statement count = count + 1 within the 'if' condition. And also you have to initialize count = 0 before the loop starts. So, count keeps track the number of media items. -Bobby Mathew

should our function be called media or gallery? the "how the ta will grade" section says gallery.
media. The other part was taken from last semester. - Bobby Mathew

anyone know how to make a proper table?
Use the
<table>
tags. - Bobby Mathew

why am i getting this before my first picture?
C:\Documents and Settings\tm171\My Documents\My Picturesgrillspic1.jpg

DELETED BECAUSE IT CONTAINED CODE!

when we add the count part, what is needed to tell JES to write that out also the height of the pic
Didn't understand the question. - Bobby Mathew



A general question that affects hw4:
Whenever I try out the small example functions from the book and slides "def makePage():" they do not generate the html file when called in the command area. All the code is perfect, copied from the book. Is it incorrect to call the function "makePage()" in the command area? Is there a command or are there parameters that I am missing?

Either the code in the book is wrong or there might be some assumptions that they make when doing it. - Bobby Mathew



ok I have no idea how to do step number 3: Your function should generate a html file named media.html

how am I supposed to generate an html file? WriteTo doesn't work

You can use the open command. file = open(dir + "//media.html", "wt"). dir is the directory you passed in as the parameter, media.html is the name of the file you need to make (it will create one for you if you already don't have one) and 'wt' is the mode you want to open the file in. In this case, its the 'write' mode. - Bobby Mathew

ok, im pretty sure that all of my code is correct, but when i load it and look at the page, the webpage is empty. is there some crucial line that i'm probably missing or something? thanks

Email your code to a TA. - Bobby Mathew

i used the open command you gave above [file = open(dir + "//media.html", "wt")]. But when I run my program, it does not create the file for me... is there something I'm missing?
If you don't have a file.close() somewhere after you open it, it won't actually create the file. -Blake O'Hare

A question about the str function... it doesn't allow me to use it within the html code (to put it in the table) and I cannot find any example in the book
str doesn't actually go in the HTML code, it's part of the python code. You use it to add calculated numbers to the end of your code. For example, when you count up how many media files are in the folder, you need to add that to your HTML code. The line to do that would look something like this...
code = code + '<p>Files here: ' + str(num_files) + '</p>'
-Blake O'Hare

OK..I emailed you Bobby...thanks for any help.

never mind... I got it.. thanks.


Thanks Blake!


How do you get the length of the sound? I tried {code = code + '' + getLength(sound) + ''} and also {code = code + '' + return len(sound) + ''} and JES had problems with both of those. I'm not sure how else I'm supposed to do this, but it's probably a combination, or just a little off, or maybe way off, haha. Help please!
wrap getLength(sound) with the str function. -Blake O'Hare

i still dont get how to add the amount of files to the bottom of the page?
You need to keep a running tally of the jpegs and waves and after you close your table, you need to add that number to the end of your HTML code. -Blake O'Hare

i'm pretty sure my code is correct, and when i run it there are no errors and it doesn't crash. it creates media.html. but when i go to open media.html, it is blank. what could be wrong?
Usually "blankness" happens when you don't close the file connection after you finish writing everything to it. -Blake O'Hare


i put the close.file at the end of the program and JES wouldn't let me do that... so i put it somewhere else in the code and it now has the topcode() part you did in recitation on the webpage, but not the table info or the bottomcode(). i've been working on this for a couple days now, and i was way off until recitation yesterday... and its still not working.

i also made the comment about the getLength ... i still don't understand how the str works in that aspect. the only place i knew how to use str was for the bottom part of the page where you list how many total files you have.

I'm having trouble with one of my lines in my code.
It keeps saying the there is a syntax error in it. Can you look at it for me??:

code = code + " Mansfield Wrotto:gtg891n "


" Mansfield Wrotto:gtg891n "

Blake (who ever)- appearantly I can't paste it on this (regarding the question above: code=code+".....") so will just e-mail it to you.

I'm getting a syntax error with this line: code = code + '' + link to file
I really don't know what I'm doing with this whole directory thing. do we have to create a directory or can we just use media sources?

ok, so I've got that (above) working. what now about: file = open(directory, '//media.html', 'wt'), I'm getting problems with this too.

sweet, thanks for the help. especially since i was at work all day and didnt see this until after 7 and no one replied to after i posted a question at like 330 yesterday...

print os.listdir("C:\Documents and Settings\Owner\My Documents\newfolder")
An error occurred while making an operating system call. Please tell a TA what you were doing when this happened, so we may correct it.

exactly what does this mean? i set media path to mediasources, then I used "new folder" for my new directory which was just an empty folder within my documents, everything seemed to work okay until this last part. HELP
It means you didn't put an r in front of the path:
print os.listdir(r"C:\Documents and Settings\Owner\My Documents\newfolder")

I thought we had to use the counting function and not the str(n) function for writing the media file count at the bottom of the page. Will there be points off if we have used either or?



Link to this Page