CS150 - Fall 2013 - Class 11

  • Exercises


  • admin
       - Lab on Friday will be a working session

  • midterm details
       - Thursday night, 7:30-9:30pm in MBH 220
       - What you can use:
          - cheat sheet handout on the course web page (I'll bring copies of this to the midterm)
          - 1 piece of paper (you may write on both sides) with notes, etc.
          - no other notes, book, etc.
       - Exam will be written
       - Practice exam available online

  • revisiting our swap function
       - could we write a function that swaps two lists? (Hint: think about assigning to a slice)
          def list_swap(a, b):
             temp = a[:]
             a[:] = b[:]
             b[:] = temp[:]

       - could we ever write a function that swapped two ints (or floats, or strings)?

          def swap_int(num1, num2):

          - no.

  • midterm review
       - key constructs
          - defining new functions (def ...)
          - for loops
             - using indices with range
             - over lists
          - if/elif/else statements
          - while loops
       - print vs. return
       - types
          - int
          - float
          - bool
          - string
          - lists
       - strings
          - indexing
          - appending/creating
          - slicing
       - lists
          - indexing
          - creating
          - aliasing
       - conditionals
          - and, or, not
       - operations
          - +, -, *, /, %
       - using modules
          - how to import them
             - from <module> import <material>
             - import module
          - random
          - math
          - turtle
       - input/output
          - raw_input
          - print
          - reading from files
       - commenting
       - good style