Midterm Review - CS112 - Spring 2009
Check for updates… this document will most likely be updated a few times!
Last update: 3/04/09 11:00 AM
Some topics to review for the midterm include (but are not limited to):
Algorithm Development
- Pseudocode - what is its purpose? Are there any syntax requirments?
Python Basics
- Indentation - why is it important, how does it define the concept of a logical block of code
- Identifiers
- what do they represent
- where are they used (functions, variable names)
- what are reserved words (or key words -- same thing)
- How to use the print function
- Use with multiple strings (with/without the comma)
- Use with print formatting
Statements versus Expressions
- Know the difference between statements and expressions and be able to identify either
- What does it mean to resolve an expression
- How do you create a statement across multiple physical lines
Data Types
- What types were discussed in class
- Know how operators affect strings, numbers
Command Line I/O (CLI)
- How to write to the command line
- How to read input from a user (and convert it to a number if needed)
- How to create a command line menu
Control Structures
- Branching: If / elif / else statements
- How do they work
- Which parts are required versus optional
- Definite Loops
- For loops - know how to write them to iterate over any sequence or a specific number of times
- Indefinite Loops
- While loops - know how to write them and when they will exit
- break statement - what is it, how does it change the control flow of the loop?
- continue statement - how does it change the control flow of the loop?
Built-in functions
- which
ones have we discussed/used in lecture and lab/project exercises, how
do they work, how are they used, what can they do for you, etc.
References/Documentation
- What is in the language reference
- What is in the library reference
- Know how to read a function specification, including understanding optional parameters
Data Structures
- Sequences - Lists, Tuples, Strings (as a data structure)
- Know how to Slicing/Indexing them
- Know how to delete from them (when possible)
- What is meant by mutable and immutable
Mutable Structures
- How to insert into lists
- How to remove values
- How to modify values
Logical (Boolean) Expressions
- Know how to use :
- and, or, not operators
- comparison operators (==, != , <,>,<=,>=)
- truth tables
Numeric Data
- Operations
- Conversions using functions (eval, bin, hex)
- Conversions using math
- Given a hex number, convert it to decimal or binary
- Given a decimal number convert it to hex or binary
- Given a binary number convert it to hex or decimal
Functions
- Know how to invoke a function
- Know how to pass parameters to a function. (What are formal versus actual parameters?)
- Define a function that returns something
- What is variable scope
Datatypes
- Know how to use and modify lists (mutable)
- Know how to use int/float/char/String/Tuple (immutable)
- Know how to slice out portions of any sequence type (it’s the same for both!)
- What is meant by mutable and immutable
Loops/Decisions
- How do you create a for loop (definite loop)
- How do you create a while loop (indefinite loop)
- Know what break does
- Know what continue does
- Know how to use if/elif/else
- How to create a text menu using a loop
File IO
- What can happen if you don’t close the file?
- Processing sequence: open, read, close
- File modes, what are the differences (r, w, a)
-
Know how to read files using at least one of these: read,
readline, readlines, for loop method. If I ask you to write code to
read a file, you should know how to do it.
- If I ask you how to write code to write a file, you should know how to do it
- What is \n ?
- What do I do with \n when reading from a file? When writing to a file?
Remember to bring a scantron!
Also check Prof. Heishman's review for another way to think about these. His Midterm Study Guide is on Blackboard under "Materials for Prof Heishman's Section --> MT Study Guide"