[Tutor] python problem
Andreas Kostyrka
andreas at kostyrka.org
Thu Mar 1 18:49:11 CET 2007
Why does that look like a homework to me? One where you are supposed to solve it by yourself?
Andreas
_____ Ursprüngliche Mitteilung _____
Betreff: [Tutor] python problem
Autor: "Purcell, Brittany Nicole" <bnpurcel at indiana.edu>
Datum: 1. März 2007 7:40:45
I have no idea how to even begin to program something like this and
what I need to do is:
To complete the skeleton by replacing ellipsis (in this case vertical)
with a solution. The number of dot indicates the number of lines of
the solution, and fill in the following dots:
def every_nth(s, n):
"""Return a string composed of every n_th character of s, starting from the
first; that is, those characters with indices 0, 1*n, 2*n, ...
>>> every_nth('abcdefg', 2)
'aceg'
>>> every_nth('abcdefg', 3)
'adg'
>>> every_nth('abcdefg', 1)
'abcdefg'
>>> every_nth('abcdefg', 20)
'a'
>>>
"""
.
.
.
.
.
.
def space_separate(s):
"""Return a copy of string s with a space inserted between each of the
characters of string s.
Use iteration over the characters of s.
>>> assert space_separate('abc') == 'a b c'
>>> assert space_separate('') == ''
>>>
"""
.
.
.
.
.
.
def reverse(s):
"""Return a string with the characters of string s in reverse order.
Implement with a while loop and indexing.
>>> assert reverse('abc') == 'cba'
>>> assert reverse('') == ''
>>>
"""
.
.
.
.
.
.
def test():
"""Tests for this file."""
# add a few tests for each function below using assert statements
if __name__ == '__main__':
test()
_______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070301/94797c7c/attachment.html
More information about the Tutor
mailing list