Homework Assignment

Functions, Exceptions

Contents:


Overview

Topic: Functions, Exceptions
Related Reading: Chapter 5
Due:

Please make sure you adhere to the policies on academic integrity.


Problems to be Submitted (20 points)

  1. (5 points)

    Write a function acronym(phrase) that accepts a string as a parameter, and returns a new string that includes the first letter of every word in the original phrase, all in uppercase. For example, a call to acronym('Laughing out loud') should return the string 'LOL'.

  2. (5 points)

    Exercise 5.25 on page 199 of the book.

  3. (5 points)

    Exercise 5.29 on page 199 of the book.

  4. (5 points)

    Exercise 5.34 on page 200 of the book (that is, an error-checking version of Exercise 5.23 of page 199)


Extra Credit

  1. (2 points)

    Write a function with signature convertBase(value,base) that takes a postive integer value and a base from 2 ≤ base ≤ 36 and returns a string representing the given interger value in that base (see discussion of Exercises 5.14 and 5.15 for algorithmic approach). As examples, convertBase(64180,16) should return the string 'FAB4', convertBase(18,2) should return the string '10010', and the call convertBase(789,10) should return the string '789'.

    (you do not need to do any error checking of the parameters for this exercise)


Last modified: Monday, 28 February 2011