Introduction to Computers and Programming
V22.0002-004
  Fall 2010
Adam Meyers
Research Assistant Professor &
Visiting Clinical Associate Professor

General Information:
Time and Place
Warren Weaver Hall
251 Mercer Street
Room 109
Mondays & Wednesdays
2:00PM--3:15PM
September 8, 2010 to December 15, 2010
(excluding holidays)
Final Exam to be scheduled some time between
December 15--23, 2010
Instructor Contact Info
715 Broadway, Room 702
meyers at cs dot nyu dot edu
212 998 3482
http://nlp.cs.nyu.edu/people/meyers.html
Instructor Office Hours
Monday, Wednesday and Thursday 11:00AM--12:00PM or by appointment
Required Text Book Visual Quickstart Guide to Python
Tony Donaldson
Peachpit Press, 2009
ISBN-10: 0321585445
ISBN-13: 978-0321585448

Course Description and Syllabus: This course introduces computer programming using the language Python 3 as a vehicle. The course will cover basic definitions (what is hardware, what is software, etc.), basics of planning programs (flow charts, psuedo-code, algorithm design), variables (initialization, assignment, scope), operators (+, -, ==), control structures (if, else, elif), iteration (using loops), functions, modules, sequences (lists, strings), among other topics (time permitting). While students will learn how to implement these concepts using Python, general principles will be taught which apply to all modern programming languages.

Test Dates: There will be two midterms and one final. The dates of these tests are given below.  Please make a careful note of these times in order to prevent scheduling conflicts.

Test
Date and Time
Sample Problems
Test/Answers/Grades
Midterm 1
Wednesday, October 6, 2010, 2:00-3:15
Sample Problem Set 1
Sample Problem Set 1 with answers
Test
Test with Answers
Number Grade/Letter Grade Conversion
Midterm 2
Wednesday, November 10, 2010, 2:00-3:15 Sample Problem Set 1 with Answers
(see talk and python scripts for Class 17)
Sample Test
Programs which give the answers:
(1) Turtle functions; (2) Other Programs
Test (with typo fixes)
Test programs (to check answers)
Test Turtle program

Number Grade/Letter Grade Conversion
Final
Monday, December 20, 2010, 2:00-3:50PM
Sample Test
The input file list-of-quotations.txt
(for one of the questions)
Programs which give the answers:
(1) Turtle functions: (2) Other Programs
Please keep in mind that: 1) This models a test that requires you to answer 7 out of 10 questions in 1:50 minutes.; 2) Extra practice portions correspond to extra credit portions for the real test.


Homework: Read the Donaldson book over the course of the semester and do the assigned programming assignments as the term progresses. This section will be continually updated as the term progresses. Grades on homework contribute 25% to the final grade for the course.

Assignment 1
See Attached.  Due Wednesday September 15                            
Assignment 2
See Attached. Due Monday September 27
Assignment 3
See Attached. Due Monday October 4
Assignment 4
See Attached. Due Monday October 18
Assignment 5
See Attached. Due Wednesday October 27
Assignment 6
See Attached. Due Wednesday November 3
Assignment 7
See Attached. Due Wednesday November 24
Assignment 8
See Attached. Due  Wednesday  December 1
Assignment 9
See Attached. Due Monday, December 6
Extra Credit Assignment
See Attached. Due Monday, December 13
Assignment 10
See Attached. Due Wednesday, December 15

Materials from Class:

Class 1
Administrative Matters Talk
Introduction to Introduction to CS Talk



Class 2, 3, 4
Second Class Talk
(includes discussion of Apple Shell Commands)
Print Statements and Data Types
How Computers Work:
Go to Course Documents
on Blackboard Page



Class 4, 5, 6
Problems in Class including date-in-future problem (Note: algorithm discussed, leaving implementation to future class)
Defining Identifiers: Objects with Names
Idle Output: Class 4
Idle Output: Class 5


Class 6, and 7
Identifiers, Functions, Variables, etc. exercises
Python Programs from Class



Class 7
Review for Midterm 1
Idle Output



Class 8
Modules and Scripts
Idle Output 1
Idle Output 2
2 Similar Python Programs: four_squares.py and four_squares2.py

Class 9
Midterm # 1 (See Above)




Classes 10 & 11
Control Structures (if, elif, booleans)
Decision Trees (diagnosis program)
goldilocks.py
diagnosis.py
Idle Output: Class 10
Idle Output: Class 11


Classes 12
& 13
Loops


Classes 13, 14 & 15
Strings:
Idle output from class 13
Idle output from class 14
Function for adding English plural -s
Imperfect program for converting number strings to numbers

Class 16 & 17
Midterm #2 Review Python Functions corresponding to sample midterm questions. Idle Output from Class 16

Idle Output from Class 17

String Functions in Python (not on Midterm)


Class 18
Midterm #2 (See Above)

Class 19
Midterm #2 Review (See Above)
Idle Output Class 19

Class 20
String Manipuation string matching functions Idle Output from Class 20

Classes 20 to 24
More Data Structures
Python File: collection examples
Future Day Problem Python Code
Turtle Command Program
Phonebook Program
Idle Output from Class 21
Idle Output from Class 22
Idle Output from Class 23


Classes 24 & 25
Input/Output IO Sample programs (read_story, take_dictation, filter_spam)
Phonebook Program (updated)
Idle Output from Class 24

Idle Output from Class 25

Classes 25 & 26
Recursion
Recursion Functions Idle Output from Class 25
Idle Output from Class 26

Classes 27 & 28
Final Review 
See Sample Final above



Installing Software:
  1. Go to www.python.org
  2. Click on Download tab on left
  3. Download Python 3.1 or greater for Windows, MAC or Linux (as appropriate)
  4. Install Python as per the instructions
    • After installing on an Apple, open up  a shell (aka "console") and type "python --version". If 3.1 (or the version you downloaded) does not print out, then you need to make some further adjustments. See instructions below about "Python 3 on an Apple".
    • After installing on Windows, you need to download the Demos as well. I put them in the attached zip file on the class website. Then, copy the folder in the zip file into the python directory. The directory would be c:/Python31/ if you install python 3.1 on Windows Vista and used all the defaults. If you have trouble accessing the files in the zip file, download and install the free program 7 zip.
Grading: 25% Homework + 20% Midterm # 1 + 20% Midterm # 2 + 35% Final
Tutoring:
Other Information:
  1. Python 3 on an Apple: (Includes some corrections) Apples often have Python 2.x pre-installed. This means that, by default, Python 2.x is used to run python programs (file type .py). This is appropriate because Python 2.x is currently more prevalent than 3.x. So, having 2.x as a default works well when you, for example, click on a python program that is on a website somewhere. This is however, kind of inconvenient for purposes of this class which is taught using Python 3.x.  Below, I will provide some information for changing the default once you install 3.x. After this course is complete, you will have the option of reversing these instructions and returning the default to 2.x.  (If you have trouble following these instructions, a graduate assistant, tutor or the instructor should be able to help.)
    1. Type "whereis python" and hit the enter key
    2. Go to the directory containing that file using the command "cd"
      • Type "cd /usr/bin" if the file is "/usr/bin/python"
    3. Find out where python3 is and pythonw3 are
      • which python3
      • which pythonw3
    4. Rename the old version of python (so that way you can change it back if you need to)
      • sudo mv python python-old
        • enter your password when prompted
    5. Create two symbolic links to the current versions of python 3
      • sudo ln -s /usr/local/bin/python3 python
        • enter your password when prompted
      • sudo ln -s /usr/local/bin/python3w python3w
        • enter your password when prompted
    6. Go to any python file in any folder (using the normal Windows or Apple GUI)
      • e.g., Applications/Python3.1/Extras/Demo/turtle/tdemo_clock.py
    7. Change the default program to open it. (Go to File/Open with/Other)
      • Select Applications/Python3.1/Python Launcher
      • Click on “always open with” and enter
  2. Python 2.x versus Python 3.x: This course will use versions of Python 3, the version of Python that is expected to be prevalent in the near future. Currently, however, most Python code available on the web and most Python text books assume some version of Python 2, including some of the free textbooks described below. Therefore, it may be necessary for students to understand some of the differences.
    • See http://docs.python.org/release/3.0.1/whatsnew/3.0.html for the full details
    • The most important differences for this class are:
      • The print statement. Python 2 allows you to omit the parentheses. Thus the statement print('Hello') in Python 3, would be rendered as: print 'hello'
      • Python 2 has two functions input and raw_input corresponding to Python 3's function input. Python 2's function raw_input is essentially equivalent to the Python 3 function input, whereas raw_input is a special case for dealing with integers. A Python 3 statement like my_number = int(input('What is your favorite number')would simply be my_number = input('What is your favorite number') in Python 2 (coersion of the input string to integer is incorporated into the Python 2 input function).
      • Integer division in Python 2 yields an integer rather than a float as in Python 3. In Python 2: 100/40 = 2 In Python 3, 100/40 = 2.5. Python 3 has an additional operator // that functions like / in Python 2.
Additional Resources:
  1. Python Resources using Safari online at Bobst (note differences between Python 2 and 3 above):
  2. Online Python Resources:
  3. Online Free Python Textbooks (note differences between Python 2 and 3 above)
  4. Introduction to Machine Code, Assembly Language, etc. (the Professor and Pat series):
  5. Computer History