Study Guide for CS 303E Test 2 (Summer 2011) on 31 Jul 2013 * Loops * Functions - user defined and built-in * Math Functions * Strings and String Functions * Reading and Writing Text Files * Lists and List Functions * The questions will be similar to quiz questions and the tutorial exercises that you have done on Coding Bat. * Here are some additional String problems that you want to consider. In all cases you will be asked to write a function. - Write a function that accepts a String as input parameter and returns True if it is palindromic and False otherwise - Write a function that accepts two Strings as input parameters and returns True if they are anagrams and False otherwise - Write a function that accepts a String and a rotation parameter and rotates the String by that amount and returns it. For example, given a String "computer" and a rotation parameter of 2, it will return "ercomput". * Here are some file manipulation problems to look at. - Write a function that accepts two Strings - the name of an input file and a target String. It will return the number of occurences of the target String in the file. - Write a function that accepts the name of an input file and a list of forbidden words. If any one of those forbidden words exists in the file it will return False and True otherwise. * Here are some list problems for you look at: - Write a function that accepts a 1-D list as input parameter and returns a 1-D list that is a copy of the input list where each element of the input list is multiplied by the same factor. - Write a function that accepts a 2-D list as input parameter and returns a 2-D list that is a copy of the input list but each element in the input list is incremented by the same number. - Write a function that accepts a 2-D list as input parameter and prints the sum of each row on separate lines - Write a function that accepts a 2-D list as input parameter and prints the sum of each column on separate lines - Write a function that accepts a 2-D list as input parameter and prints the sum of each diagonal. Assume that the 2-D list is square. - Write a function that accepts an input parameter n (that is a positive integer) and returns a 2-D list containing all the numbers from 1 through n (inclusive), their squares, and their cubes. For example if n was 5 your function will return the following 2-D list: [[1, 1, 1], [2, 4, 8], [3, 9, 27], [4, 16, 64], [5, 25, 125]] - Write a function that accepts a 1-D list of integers and returns True if all the numbers are in ascending order and False otherwise. (It will return True if all the elements are the same.) - Write a function that accepts a 2-D list and returns a 2-D list with all the rows reversed. - Write a function that accepts a 2-D list and returns a 2-D list with all the columns reversed. - Write a function that accepts a 2-D list and returns a 2-D list that is the transpose of the input list, i.e. the rows and the columns have been switched.