|Welcome to CS1315. Click on the python to add comments.|
|This page removed for FERPA compliance|
Review for Test3 - Spring 2007 Questions
I am trying to do the string reviews, but I don't understand the results that I'm getting on JES for the last part of the program: "printNow (string.split ('t')). I understand that printNow prints the results immediately and that split makes a list out of the string, splitting the string at the t. What I don't understand is why JES prints ['Massachuse', ",'s']. Why is there a double quote in the middle?
Post your questions here and a TA will answer them.
What is the direction for the Howey Physics L1? can you give a direction from the CoC building? Thanks
Howey Physics is across the street from the CoC. L1 is the last room on the left as you enter the building. You'll probably see people walking in.
can someone explain the max and min functions for a string (i.e. max(string) and min(string)) are the values calculated alphabetically or sequentially? When I try to run the min value for the string "Massachusetts" the letter M is returned, but when I try and run the max value for the same string, I get u. The book does not provide a substantial explanation of this either.
Figuring out how to sort the list should give you a clue as well.
What is the difference between: string.count('n') and string.count("n")?
Could someone help me with the answers and explanation to the "String & List tracing" topic of the review?
|It was announced that no answers would be posted to the review. That is what the review session was for. Please visit a TA's office hours if you feel that you need REMOVED help. Also, tracing can just be copied and pasted into JES for the answers.-Brittany Duncan|
How do you know what functions are in a module?
|You just need to know the ones on the review. - Bobby Mathew|
On the following coding question, "(11) Write a function named greaterString() that takes in two strings and returns the one that is greater.", what is meant by "greater"?
|Which letter is greater. If you have 2 strings, one starting with 'b' and one starting with 'c', the second string is greater. - Bobby Mathew|
for the modules: should we just focus on learning the actual imports and when to use them, or should we also know how to write all of that code that goes along with them?
|You mainly need to know the module and the function it uses but you have to understand what the rest of the code does. - Bobby Mathew|
When you use print max(list) and the list is a list of words, is the max just the letter or the combined values of he whole word?
[Q: This code does not work in JES. I did dir = setMediaPath() at the bottom and then ran this code and there is an error on line3.
#(6) Count how many .jpg files in a directory
import os #Not strictly necessary, because this module is imported automatically
file_list = os.listdir(dir) #Get all of the files in the directory 'dir' and put them into a list
count = 0 #Start count at zero
for file in file_list: #Loop to go through evey file name in the list
if file.endswith('.jpg'): #REMOVED each file name to see if it ends with '.jpg'
count = count + 1 #If it does end in '.jpg' then add 1 to count
return count #Return the accumilated sum of countthe error is this:
The error was:java.lang.NullPointerException
I wasn't able to do what you wanted.
The error java.lang.NullPointerException has occured
Please check line 3Is file_list = os.listdir(dir) right?]
|It should work. Instead of putting setMediaPath, try doing >>> dir = "C:\\.........". In any case, the code that you filled in is right. - Bobby Mathew|
i dont think we are gonna get any of these questions answered...
|It's just late..........sorry. Hope you still get these in time. - Bobby Mathew|
I am concerned as to how we will be graded on our answers. On the review, in strings, my answers just look like, for example, Massachusetts. But for lists, they look like, for example, ['bread']. Is this how they should be answered or should every one have brackets around it? I think this was answered at the review session, but I want to make sure I heard correctly. Thanks!
Link to this Page