Working with Text

1.

   a.'ComputerScience'
   b."Darwin's"
   c.'H2OH2OH2O'
   d.''

2.

   a. "They'll hibernate during the winter."
   b. '"Absolutely not," he said."
   c. '''"He said, 'Absolutely not,'" recalled Mel.'''
   d. 'hydrogen sulfide'
   e. 'left\\right'

3.

   'A\nB\nC'

4.

>>> len('')
0

5.

   a. print('The rabbbit is ' + str(x) + '.')
   b. print('The rabbbit is', x, 'years old.')
   a. print(y, 'is average.')
   a. print(y, '*', x)
   a. print(str(y) + ' * ' + str(x) + ' is ' + str(y * x) + '.')

6. Doe, John

8.

def repeat(s, n):
    """ (str, int) -> str

    Return s repeated n times; if n is negative, return the empty string.

    >>> repeat('yes', 4)
    'yesyesyesyes'
    >>> repeat('no', 0)
    ''
    >>> repeat('no', -2)
    ''
    >>> repeat('yesnomaybe', 3)
    'yesnomaybeyesnomaybeyesnomaybe'
    """ 
    return s * n