CSC 221: Computer Programming I
Test 2 Review

Wed, Nov 16
  • As with Test 1, the test will contains extra points (e.g., 53 out of 50).
  • As with Test 1, the test will include a variety of questions (e.g., TRUE/FALSE, short answer, trace/modify code).
Study advice
  • review online lecture notes (if not mentioned in class, won't be on test)
  • review online text
  • look over quizzes, homework assignments
  • reference other sources for examples, different perspectives
Course Material   
Turtle graphics module
  pen control functions: pendown, penup, setup, reset, home
  drawing/motion functions: forward, backward, left, right, goto
  examples: random walks, alphabet drawings

  common operations/functions: 
    +, *, len
    indexing via [i]
    slicing via [s:e] and [s:e:n]
    can traverse using 'for X in SEQ: ... X ...'
    can traverse using 'for i in range(len(SEQ)): ... SEQ[i] ...'
    can test membership using 'X in SEQ'
  each type of sequence has its own type-specific methods
      unlike functions, called as str.METHOD(INPUTS)  
    sequence of characters, immutable
      type related: isalpha, isupper, islower, isspace
      case related: capitalize, upper, lower
      format related: center, rjust, strip, rstrip
      search related: count, find, replace
    traversing a string
      by character vs. by index
      building a copy of a string, char-by-char
    examples: palindrome, Caesar cipher, Pig Latin 
    sequence of arbitrary items, mutable
      search related: count, index
      order related: sort, reverse
      modifiers: append, extend, insert, remove
    strings to lists
      string split method
      splitting user input into words/numbers
    examples: dice stats, averaging, acronym, Pig Latin phrases
  user input
    input: good for numbers, strings require quotes
    raw_input: good for strings, numbers must be converted (int, float)
    open a file using open function
      open(filename, "r") & open(filename, "w") return file objects
    file input methods:
      read() vs. read(N) vs. readline() 
    close a file using close method module
      askopenfilename & asksaveasfilename functions