Math 146 - Programming I - Spring 2017

Department of Mathematics and Information Technology

Mercyhurst University

Handouts and Presentations



Algorithm Pseudocode Example/Slides - Examples of algorithm pseudocode for a simple programming project and an explanation of the scores.

Exam 1 Review - Exam 1 will be based on the material from Chapters 1, 2, and 3, and parts of Chapters 5 and 7.  This list of topics is not exhaustive - there may be some topics covered on the exam that are not listed here.  The exam will be held in class on Wednesday, February 22nd.

Exam 2 Review - Exam 2 will be based on the material from parts of Chapters 5 and 8 and all of Chapters 6 and 7. This list of topics is not exhaustive -  there may be some topics covered on the exam that are not listed here.  The exam will be held in class on Wednesday, April 5th.


Chapter 5 - Sequences: Strings, Lists, and Files
encoder.py - Converts text into a sequence of Unicode numbers.

decoder1.py - Converts a sequence of numbers into a string of text using strings.

decoder2.py - Converts a sequence of numbers into a string of text using a list.

stringFormatting.py - Examples using the string formatting methods.

userNames.py/names.txt - Create user names from a text file.

Chapter 6 - Defining Functions
userNames_Function.py - Uses a function to create user names.

Function Practice - Can you write the code for these functions?
rectangleArea_Template.py
squareList_Template.py
maxNum_Template.py

Chapter 7 - Decision Structures
profitLoss.py - Use nested if/else statements to determine if a company breaks even, or if it has a profit or loss.

profitLoss2.py - Use if/elif/else statements to determine if a company breaks even, or if it has a profit or loss.

exceptionHandling.py - Use exception handling when trying to use the quadratic equation.

Chapter 8 - Loop Structures and Booleans
average_forLoop.py - Compute the average of n numbers using a for loop.

savingsAccount_whileLoop.py - Simulate an ATM using an interactive loop.

average_sentinelLoop.py - Compute an average using a sentinel loop.  In this example the sentinel value is a negative number.

average_sentinelLoop2.py - Compute an average using a sentinel loop.  In this example the sentinel value is an empty string.

multiplicationTable.py - Use nested loops to print out a multiplication table.

numberPyramid.py - Use nested loops to print out a pyramid of numbers.

examAvg.py - Compute an average where the lowest exam is dropped.

average_loopAndAHalf.py - Compute an average using  a loop and a half.

Chapter 10 - Classes and Inheritance
Rectangle.py - A typical class definition.

savingsAccount.py - Implement a savings account/ATM simulation example using a class to represent the account.

Classes and Inheritance - Notes for the end of Chapter 10.

RectangleList.py - How to add objects to a list.

subclass.py - Creating a subclass (i.e., derived class) of a base class.

isinstance.py - How to use the isinstance function.

rpg.py - Simulating a simple RPG using a class.

graphics.py - The graphics library written by the author of our textbook.