Introduction to Computers and
Programming
CSCI-UA.0002-001
(aka,
V22.0002-001)
Summer 2011
Adam
Meyers
Research Assistant Professor &
Visiting Clinical
Associate Professor
General Information:
Time and Place |
Warren Weaver Hall May 23, 2011 to June 30, 2011 (no
class June 23, 2011) |
Instructor Contact Info |
715 Broadway, Room 702 |
Instructor Office Hours |
Tuesday and Thursday 12:00PM--1:00PM |
Required Text Book |
Visual Quickstart Guide to Python |
Optional Text Book |
Starting Out with Python (Second Edition) |
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.
Prerequisites: Anyone interested and willing to learn about computer science and programming can take this class. However, some proficiency in High School math (algebra, geometry) is assumed. As with any mathematically oriented class, the concepts learned build on each other and it is not advisable to join the class late in the term (beyond the third class). This class is also a prerequisite for V22.0101.
Previous Class Website: For more information, please examine websites from previous classes, such as V22.0002.004 (Spring 2011).
The current lectures and class structure may be
similar, but will not be identical to what is indicated on this
previous class website.
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 |
Tests/Answers/Grades |
Midterm |
Midterm: Monday, June 13, 2011, 9:30-11:05 AM |
Sample
Midterm
|
The midterm: midterm.pdf |
Final |
Final Exam: Thursday, June 30, 2011, 9:30-11:05 AM |
Sample
Final |
|
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. Initial Homework
Descriptions will be revised as the term progresses -- Initial
descriptions are based on the class during the year.
May 24, 2011 |
|
May 26, 2011 |
|
May 31, 2011 |
|
June 2, 2011 |
|
June 7, 2011 |
|
June 14, 2011 |
|
June 16, 2011 |
|
June 21, 2011 |
|
June 23, 2011 |
|
June 27, 2011 |
|
Extra Credit (Optional) |
June 27, 2011 |
Class Schedule with Materials from
Class Attached: This schedule and the attached materials
will be revised throughout the class (as needed). Preliminary
versions of the materials are based on the previous semester's class:
Class 1 |
||||||
Classes 1,2,3 |
First Python Talk (Print statements, Data Types, etc.) How Computers Work:Go to Course Documents on Blackboard Page |
|||||
Class 3 |
In Class Exercises (with pseudo code answer to Day in the future problem) |
|||||
Class 3,4 |
|
|||||
Class 4,5 |
||||||
Class 5,6 |
Modules & Scripts (and turtles) |
Idle Output Class 6 | ||||
Class 6 & 7 |
Flow
of Control |
|
Idle Output Class 6 (repeated) | |||
Class 7 & 8 |
asterisk_triangle_001.py
(written in class) |
Idle
Output Class 7 Idle Output Class 8 |
||||
Class
8 & 9 |
Midterm
Review Part I |
See
Sample
Midterm (answers above next in midterm schedule) |
Idle
Output Class 8 (repeated) |
|||
Class 9, 10, 11, 13 & 14 |
morphology.py
|
number_program
(in class version) |
Idle
Output Class 9 Idle Output Class 10 Idle Output Class 13 |
|||
Class 10 & 11 |
Midterm Review Part II |
Sample
Midterm |
Idle
Output Class 10 (repeated) |
|||
Class
12 |
Midterm
Exam |
|||||
Class 13 |
Post- Midterm Review |
See Midterm and Answers in Table of Tests |
|
Idle Output Class 13 (repeated) |
||
Class
14 |
String Manipulation | regexp-experiments.py | Idle
Output Class 14 |
|||
Classes 14, 15, 16 & 17 |
future-days.py |
Idle
Output Class 14 (repeated) |
||||
Classes 17 & 18 |
Idle
Output Class 17 (repeated) |
|||||
Classes 18, 19 & 20 |
Sample Final Answer Keys: (1) Turtle Question (Question 7); (2) All Other Questions; (3) list-of-quotations.txt (Read in by question 4) |
Idle
Output Class 18 (repeated) Idle Output Class 19 Idle Output Class 20 |
|
|||
Classes 20 & 21 |
recursion-functions.py british-royal.txt (used with geneology functions) 001_recursive_examples.py (includes examples from class for both days) |
Idle
Output Class 20 (repeated) |
||||
Class 22 |
Final |
|
|
|
Installing Software:
Go to www.python.org
Click on Download tab on left
Download Python 3.1 or greater for Windows, MAC or Linux (as appropriate)
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 + 33% Midterm + 42% Final
Please keep in mind the Computer Science Department's Statement on Academic Integrity
Tutoring:
During the Summer, there are no official tutoring arrangements. I am happy to answer questions during my office hours.
Other Information:
Python 3 on an Apple: 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.)
Type "whereis python" and hit the enter key
Go to the directory containing that file using the command "cd"
Type "cd /usr/bin" if the file is "/usr/bin/python"
Find out where python3 is and pythonw3 are
which python3
which pythonw3
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
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
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
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
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:
Python Resources using Safari online at Bobst (note differences between Python 2 and 3 above):
Python in a Nutshell http://proquest.safaribooksonline.com/0596100469
Python Cookbook http://proquest.safaribooksonline.com/0596007973
Online Python Resources:
The official Python website: http://python.org/
The Python Wiki: http://wiki.python.org/moin/FrontPage
Online Free Python Textbooks (note differences between Python 2 and 3 above)
How to Think Like a Computer Scientist - Learning with Python 2nd Edition by Jeffrey Elkner, Allen B. Downey, and Chris Meyers: http://openbookproject.net/thinkcs/python/english2e/index.html
Text Processing in Python by David Mertz: http://gnosis.cx/TPiP/
Introduction to Machine Code, Assembly Language, etc. (the Professor and Pat series):
Computer History