Here is a quick summary of Python topics that you should be reviewing for the final exam.
- Programming Mechanics
- Functions (what are they, using them, arguments, return values, etc)
- Variables (what are they, creating them, using them, naming rules, etc)
- Reading input from the keyboard with the input() function
- Math Expressions
- Writing math expressions
- Evaluating math expressions
- Storing & printing the results of math expressions
- Data Types
- Strings
- Numeric data types
- Integers (int)
- Floating point numbers (float)
- The Boolean data type
- The List data type
- Mixed type expressions
- Type conversion (string to int, int to strings, etc)
- Basic String Manipulation
- Combining two strings (concatenation)
- Multiplying a string (x = 'hi' * 5)
- Case manipulation (x = str.lower('JaSOn') # converts the string literal 'JaSOn' to 'jason)
- Calculating string length using the len() function
- Selection Statements
- The structure of an IF statement (IF keyword, condition, colon, indentation)
- Writing a condition for an IF statement
- Boolean operators (<, >, ==, !=, >=, <=)
- Comparing numeric values using Boolean expressions
- Comparing string values using Boolean expressions
- Using the IF-ELSE statement
- Nesting decision structures (IF statements inside other IF statements)
- The IF-ELIF-ELSE statement
- Logical operators (and, or, not)
- Generating random numbers using the random.randint() function
- Condition Controlled Loops (while loops)
- mechanics & how they work
- setting up conditions for a while loop
- infinite loops and how to avoid them
- sentinels (defining a value that the user enters that causes the loop to end)
- input validation loops (asking the user to continually enter a value until that value matches some condition)
- Accumulator variables
- setting up and using accumulator variables
- self referential assignment statements (i.e. counter = counter + 1)
- augmented assignment operators (i.e. counter += 1)
- Count Controlled Loops (for loops)
- mechanics and how they work
- iterating over a list (i.e. for x in [1,2,3,4,5]:)
- using the target variable in a for loop
- nested loops (i.e. loops inside of other loops)
- Functions
- mechanics and how functions work
- the "black box" model
- function definitions
- arguments
- return values
- calling a function
- local variables (variables that are defined inside a function and can only be accessed inside that function)
- passing arguments to your own functions
- writing a value returning function (i.e. using the 'return' keyword to send a result from your function to the part of your program that called that function)
- Lists
- Simple Variables vs. Lists (simple variables can only hold one piece of data, but lists can hold multiple values) – you can think of a list like a "book" and a variable like a "sheet of paper"
- Defining lists in Python (i.e. mylist = [1,2,3])
- Concatenating lists with the "+" operator
- Repeating lists with the "*" operator
- Referencing list items using index notation (i.e. mylist[0])
- Iterating through a list using a "while" loop
- Iterating through a list using a "for" loop
- Using the len() function to determine the # of items in a list
- Updating the value of an item in a list using bracket notation
- Creating empty lists
- Finding an item in a list using the "in" operator
- Adding items to a list using the append method
- Sorting items in a list using the sort method
- Reversing items in a list using the reverse method
- Finding the position of an item in a list using the index method
- Inserting an item in a list at a specific index using the insert method
- Finding the largest and smallest values in a list using the min and max methods
- Totaling the values of all elements in a list using an accumulator variable
- Removing an item from a list using the remove method
- Strings Manipulation
- Iterating through all characters in a string using a for loop
- Indexing a specific character in a string using bracket notation
- Iterating through all characters in a string using a while loop
- String immutability (you can't change a string using bracket notation like you would change a list element)
- Testing a string for substrings using the "in" operator
- Detecting character types in a string using the built-in string testing methods (isdigit, isalpha, isalnum, islower, isupper, isspace)
- Splitting a string into a list using the "split" method
- File Input & Output
- Opening a file for reading