Unit Testing
Publicity
Would you like to get your name, or the name of your project, in the newspapers?
Here are some of the more well-known stories about computer programs:
Mariner 1 to Venus-Incorrect data smoothing caused the spacecraft to be
destroyed
Variables and Values
Names
Variables (which hold values) and functions (which are
blocks of code) both have names
Names must begin with a letter and may contain
letters, digits, and underscores
Names are case-sensitivetotal, TOTAL, and
Total are three dif
Functions
Execution order
When you load and run a Python module (file), the statements and definitions in the file
are executed in the order in which they occur
Executing a def defines a function, it doesnt run the function
Functions are only run when the
Errors
And How to Handle Them
GIGO
There is a saying in computer science: Garbage in, garbage out.
Is this true, or is it just an excuse for bad programming?
Answer: Both.
Heres what you want:
Can you do it?
Errors and exceptions
Your program isnt alone i
Just Enough Python
Python 3 and IDLE
We will use version 3.x of Python (where x is the most recent
version
Differences between Python 2 and Python 3 are mostly minor, but
can be confusing
Python comes with an IDE (Integrated Development
Environment) calle
Data Structures
Lists, Tuples, Sets, Dictionaries
Collections
Programs work with simple values: integers, floats, booleans, strings
Often, however, we need to work with collections of values (customers,
books, inventory items, etc.)
Python supplies four k
More About Values
Casts
To cast is to take a value of one type and return the corresponding value of
some other type (or an error, if the cast is impossible)
int(x) casts a string, float, or boolean x to an integer
float(x) casts a string, integer, or boo
Using IDLE
Basic use of IDLE
Start IDLE
You can type simple expressions and code directly into the shell window
that comes up
You can use the up-arrow to go back and repeat previous lines
This is convenient for trying things out, or to use as a calculator
Math
The math module
import math will let you use quite a lot of built-in mathematical
functions
math.pi and math.e are the values and e, respectively
math.log(x, base), math.log2(x), and
math.log10(x) return logarithms of x
math.pow(x, y) returns x raise
More About Loops
while loops
The while loop is the simplest kind of
loop
The test is performed before the
statements are executed
Thus, if the test is initially False,
the while loop does nothing
If the test is True, the statements are
executed, then the
Spring, 2016
CIT 590
Programming Languages and Techniques
Homework 10
All deadlines as per canvas
This homework deals with the following topics
* Designing a user interface.
* Working with some starter code (not doing everything from scratch).
* Making so
Spring, 2016
CIT 590
Programming Languages and Techniques
Homework 4
This homework deals with the following topics
* dictionaries, sets and lists
* databases using dictionaries (not too far from how they really work!)
* test driven development (TDD)
Gener
Recitation 4
Recitation Questions.
The first few questions are from last week. Let us know which ones you want us to
discuss.
1. a) There are 32 first year MCITs and as part of 591 recitation they are told to randomly pair up and do pair programming. How
Recitation 3
Recitation Questions.
1. a) How many base 10 numbers have 5 digits.
b) How many 5 digit numbers have no two consecutive digits equal.
c) How many have at least 1 pair of consecutive digits equal.
SOLUTION:
a) 9 10 10 10 10 = 9 104
b) 9 9 9 9
Recitation 3
Recitation Questions.
1. a) How many base 10 numbers have 5 digits.
b) How many 5 digit numbers have no two consecutive digits equal.
c) How many have at least 1 pair of consecutive digits equal.
2. A palindrome is a word that reads the same
Recitation
Recitation Questions.
1. What is R Q? What is Q Z?
2. What is P (P ()?
3. For the sets A, B, C as defined below
A = cfw_1, 2, 5, 8 B = cfw_3, 4, 1, 2, 7 C = cfw_3, 2
what is
A B, A B, A C, C A, A B
4. List the elements of this set explicitly
cf
ADT
algorithm
ArrayList (java)
arrays (as a data structure)
arrays (as an ADT)
big oh notation
blackbox testing
boundary value analysis
chaining (hash)
circular linked list
class diagram
collision (hash)
collision resolution strategies
compression functio
ADT
adapter
adjacency list
adjacency matrix
algorithm
anti-pattern
ArrayList (java)
arrays (as a data structure)
arrays (as an ADT)
big ball of mud
big oh notation
binary expression tree
binary search tree
binary tree
black height (red-black tree)
blackbo
Growth of functions
10/8/09 3:49 PM
Growth of functions
We assume that 1 operation takes 10-6 seconds.
All times are approximate. Missing entries are too large to include. For
comparison, the number of atoms in the universe has been estimated at
somewhere
Welcome!
CIT 595
Computer Systems
Programming
Spring 2016
Instructor: Chris Murphy
UPenn CIS faculty member since 2010
Director of MCIT since 2014
PhD-Computer Science, Columbia University
Seven years experience in software industry
BS-Computer Engineerin
Announcements
Homework #1 will be posted soon
Due next Friday Jan 29 5:00pm
Please read and understand the section on
Academic Honesty
This weeks office hours will be posted in Piazza
Last Time
Course overview
The stack revisited
Pointers
Schedule
Today:
CIT 595 Spring 2016
Solutions to Practice Questions for Exam #2
C+ Operator Overloading, STL, and Templates
Questions #1 - 3 refer to the following class, which represents an int array and its size:
class MyArray cfw_
private:
int* p;
int size;
public:
My
CIT 595 Spring 2016
Practice Questions for Exam #2
This document contains questions that you can use to practice for the second exam.
This is not a sample exam! Nothing should be inferred about the length of the exam, the difficulty
level of the exam, or
CIT 594 Homework 4
Milestones
This homework has three milestones with the following points and deadlines:
Milestone 1 Design (30 points)
Due Monday, Mar. 21, at 12pm
Milestone 2 Implementation (70 points)
Due Monday, Mar. 28, at 12pm
Milestone
design patterns
What are design
patterns?
A general reusable solution to a commonly occurring
problem.
A description or template for how to solve a problem
that can be used in many different situations.
For example
Gang of Four
Types of design
patterns
C