Lab 4

Due 1:30PM February 21, 2007

  1. Write a for or while loop to print a string backwards.
  2. Write a program that prompts the user for two strings and determines the number of two-character sequences that appear in both the first and second strings. Exclude spaces in your comparison.
    “CS is cool” “the old cow” would have two matches “co” for “cool” and “cow” and “ol” for “cool” and “old”
  3. Implement a program that uses a loop to prompt the user for a series of strings (using “quit” to end input) and appends each string to the end of a list as it is entered. Next, use a loop to print each item in the list and, for each item, as the user if he/she would like to delete the item. If the user responds "yes", delete the item. If the user responds "no", leave the item in the list. Finally, use a loop to print all elements remaining in the list.
  4. Implement a function that takes as input a list of integers. Your function will iterate through the list and, for each element, add five to the element and replace the original value in the list with the new value. Following is a sample call to the function:

    list = [4, 5, 6, 7]
    adder(list)
    #output of for loop below should be:
    #9
    #10
    #11
    #12
    for i in list:
        print i


Sami Rollins