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 Fall 2005: String Fun


This is difficult since I am not sure what the for loop is exactly doing.
What variable is stored in loc and how did it get there in def thingamabob?
And what does "<> -1" mean?
Say I have string = "hello", and I then run n = string.find(h). What will the value of n be? What would be the value of n if i did string.find(z)? So what I am asking is what happens when JES can not find what you are looking for in a String? -Albert d'Heurle

what does "<>" mean? is it some sort of inequality?
<> means not equal -Albert d'Heurle

print "Thix\bs is\na\btest"
This is
atest

i don't understand this, it was in the ppt presentation in class, textmanipulation

For the test, know that \n represents a new line. \b is unimportant. -Blake O'Hare

why does the varibale source have to different values?
The 2nd part is calling a function to make the original source all lower-case letters. Amanda Bennett

so does the first function prints
Geor a Institute of Technology
No. Amanda Bennett

i said that i=5, since in Georgia, i is the 5th character, right? so does the first function prints
Geor a Institute of Technology
No. Recognize what the for loop does. Amanda Bennett


so for the second function, i=5, so source= georg a source of technology, but while asks to look for i in new source, but there isn't one, so it returns an i?
Not quite. Amanda Bennett

i'm sorry, not an i, i meant to say -1
Not quite. If the location is -1, does it return out of the function then? Amanda Bennett

so for the second function, i=5, so source= georg a source of technology, but while asks to look for i in new source, but there isn't one, so it returns an -1?
See above. Amanda Bennett


so for function one, it will print out Georg a Institute of Technology since the source=Georgia Institute of Technology
and i is located at 5, and [:5]is Georg and [6:] is a Institute of Technology.
No. Remember, there's a for loop there. It will go through each vowel. i in this case is not a string...it's a variable Amanda Bennett

so for function 2, i=5 and
[:5] is Georg and [6:] is a Institute of Technology, but the while function makes us recheck it and in our new source=Georg a Institute of Technology i=7, so [:7] is Georg a and [8:] is Institute of Technology, do we keep going in this same cylce till there aren't anymore i's?
No, but you do need to do it for the other vowels... Amanda Bennett

What does source = source[:loc] + source[loc + 1:] and loc = source.find(i) do?
It prints out the string without a letter (source = source...). loc=source.find(i) will find the location of whatever vowel you're on in the for loop. Amanda Bennett





Does the first one returns: grg institte of technology... coz it takes out the vowels just once?
For the second one: grg nsttte f tchnlgy?
excellent Amanda Bennett


im really confused about the second one.. any hints??
It's going to look for each letter continuously until there are no more in the function. Once it finds the letter, the function effectively removes that letter from the string. Amanda Bennett

are these correct:
1. Grg Institte of Technology: takes the first a, e, i, o, u out of the string
2. Grg nstt f Tchnlgy: takes every a, e, i, o, u out of the string
is this what the code is doing?
Close. what does source.lower() do though? Don't forget that. Amanda Bennett

1. grg institte of technology
2. grg nstt f tchnlgy

when i ran this in JES, for the second part I got - "g gy"?? Any help??
it could be a number of different things. you need to make sure that you copied it in correctly and that the code is exactly the same. -poof #10



Link to this Page