Previous Lecture Lecture 17

Lecture 17, Thu 12/06

Final Review

CS 8 Final Exam Review

'''
## Advice on how to prepare
    - Lecture notes (important to know topics, examples,
    concepts).
    - Review code written in lecture 
      - Type out the code and understand the output 
    - Understanding labs and being able to implement them
    - Reading the textbook for additional details and
    understanding
        - Do the examples to solidify understanding
    - Homework exercises
    - Prototyping - "I wonder how python behaves when ..."
        - write a simple example
        - Helps with code practice as well as understanding the language and edge cases

## Overview of topics covered after midterm 2

* File I/O
    - Read file (infile = open('example.txt', 'r'))
        - infile.read()
        - infile.read(n)
        - infile.readlines()
        - infile.readline()
        - for a_line in infile
    - Write file (outfile = open('example.txt', 'w'))
    - Append file (outfile = open('example.txt', 'a'))
        - outfile.write(somestring)

* Dictionaries
    - key / value pairs
    - Creating a dictionary
    - Adding to a dictionary
    - dictionary methods
        - .pop(key)
        - .get(key)
        - .keys()
        - .values()
        - .items()

* Sets
    - Collection of items with no duplicates
    - Creating an empty set or a set from a list
    - Set operators
        - in, not in, combine(|), intersection(&), difference(-), unique(^)
    - Set comparisons
        - ==, !=, proper subset (<), subset (<=)
    - Set methods
        - .add, .clear


* Recursion
    - Properties of recursion
        - base case
        - recursive calls getting "closer" to base case
    - Examples in class and lab
        - print
        - reconstruct lists and strings (reverse a string or list)
        - computing values (factorial, fibonacci, ...)
        - etc.

## Topics covered before midterm 2 (refer to previous lecture notes)
- Python data types
- Arithmetic
- Python built-in functions
- Comparison operators
- Boolean operators
- Strings
- Lists
- Tuples
- User-defined functions
- Namedtuples
- Testing (assert / pytest)
- For loops
- Nested control structures
- Accumulator Patterns
- Nested (double) for loops
- While loops
    - Break, continue, pass
- 2D Lists
- String functions and formatting
- Random
'''