Why are these homework programming challenges so recognisable? It boils down to: Write a function that that uses X and Y techniques. The function may be hard and challenging to write but doesn't ever do anything interesting or anything that is useful and complete on its own.
I realise teachers have to test mastery of certain techniques, but they seem to lack the imagination. Especially with modern languagues like Python, where you can write a whole program that actually does something usefull using only a few lines of code it should not be necessary to ask these kinds of dull questions. Just stick at it Natasha, it is far more interesting when you the programming challenge has to accomplish a real result. Ben --- Natasha Menon <[EMAIL PROTECTED]> wrote: > Hi, > > I have a few doubts in python programming. C if > any of u can help me out. > > 1. > In a file called string_stuff.py i have to write a > function called frequencies that takes a string as a > parameter and returns a dictionary where the keys > are the characters from the string and each value is > an integer indicating the number of times the key > appeared in the string. > > 2. > Similary in the same file string_stuff.py, have to > write a function called locations that takes a > string as a parameter and returns a dictionary where > the keys are the characters from the string and each > value is a list indicating the indices in the string > at which the key appears, sorted in increasing > order. > > 3. > In the same file string_stuff.py, write a function > called concordance that takes an open file as a > parameter and returns a dictionary where the keys > are the strings from the file and each value is a > list of line numbers of the lines in which the key > appeared, sorted in increasing order. Start counting > at 0. Each line number should appear at most once in > a list, even if a word appears twice on a line. You > may assume that the input consists only of > alphabetic letters (a-z, A-Z) and whitespace. > > > Id really appreciate if you could help me on these > small question. I am tryin to learn to program in > python. > > Thanks, > Natasha > > > --------------------------------- > Brings words and photos together (easily) with > PhotoMail - it's free and works with Yahoo! Mail.> _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___________________________________________________________ Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor