Location: 224 Johnson Hall
Times: Tues/Thurs 8:30-10:00
TA: Nancy Decker (nkdeck07)
Office: 106 Bewkes Hall
Hours: Wed/Thurs 3:00-4:00
TA hours: Thurs 7:00-9:00pm
|About the course|
|This course will
introduce you to computer science,
one of the most
important fields of the 21st
century. It is a field
with potential to help solve many important problems. It is
challenging and rewarding, and it requires both technical precision and
In this course, you will begin to learn:
Prerequisites: None. This course is intended for students who have not done any programming.
Textbook: There is no textbook to buy. Instead, I will direct you to online readings chosen specifically for each topic.
|This course has a final
project instead of a final exam in
order to let you explore an area of interest to you. For this
project, you will design and write a non-trivial program of your choice.
If you normally work with a partner, you may work together on the project, but you may also choose to work separately if your interests are in different areas.
Ideas for topics
You don't have to use one of these ideas-- you can propose an idea of your own as well.
Thursday, December 3: Webpages and HTML. Class example: webpage.html
Tuesday, November 17: Artificial Intelligence (AI). Class examples: tictactoeAI.py
Thursday, November 12: Computer games. Class examples: tictactoe.py
Thursday, October 29: Graphics in Python. Class examples: drawing.py
Tuesday, October 27: In-class exam.
Thursday, October 22: Review for the exam on Tuesday in class.
Tuesday, October 6: Lists. Class examples: months.py
Tuesday, September 29: Review and practice for the exam tonight at 7pm in Bloomer Auditorium.
handbook outlines the
university's policies on academic
honesty. The university's main expectations are:
In this course, here are some specific expectations:
|Working in Pairs|
with another person will help you correct each
others' misunderstandings, see alternate ways of approaching difficult
programs, and learn with a broader perspective than you would
alone. A challenging class can also be much more enjoyable
you're working with others. The very real possibility of
benefits is the reason I do encourage collaboration on homework.
To get the benefits, though, you have to go about
the right way. Here are some basic suggestions for doing so.
Before working with a partner: Outline the program by yourself. Some programs may be simple enough not to need pair programming at all. Others may be difficult enough that you can only really contribute if you've done some thinking already.
While working with a partner: Make sure that each partner takes control of the keyboard for about half the assignment. It will be tempting to have the faster typer or the stronger programmer at the keyboard the entire time. Resist the temptation! Remember the point is not to finish the program in front of you as fast as possible; the point is for both of you to develop your programming skills.
After working with a partner: Both partners should turn in the same code, and both partners' names should be in the files.
|The official Python website
is the definitive source for information, but below are some
Installing and Running Python
Coding in PythonThis is the first semester that CS 140 is using Python, which means that the TAs may not be familiar with the language. Don't be concerned though; Python has a great deal of similarity to Java, which the TAs will know. They may need to consult the Python documentation about syntax differences, but the ideas are the same. To make this easier, here is a quick-reference list of differences between Java and Python syntax.
Python is intepreted, not compiled.
Code can be run one line at a time in the interpreter. It can also be run from a file, but there's no separate compile step as there is in Java.
Python can have code outside of any class or method.
While Python is object-oriented, it does not require a program to contain any classes or even a main method as Java does.
Python comments start with #
Unlike the // symbol in Java.
Python variables do not have to be declared.
You can introduce and use a Python variable without declaring a type as in Java.
Python does not use semicolons.
Lines do not have to end in semicolons as in Java. There are some regular colons in Python, though -- at the top of an indented block for a loop, function, etc..
Python does not use brackets.
Loops, functions, etc. do not use any brackets. Instead, you indicate what is inside a loop, function, or other block purely by indentation. The convention is to have code start with 0 spaces, to put code inside a top-level loop 4 spaces in, to have the next level 8 spaces in, and so on.
Whitespace at the beginning of the line matters in Python.
Since indentation is meaningful, each line must have exactly the right number of spaces before it, or there will be an error. It could be an interpreter error, say if the first line of a program has a space in front of it, or the code could just not work as intended, say if a line meant to be inside a loop doesn't have enough spaces in front of it.
Python arrays are called lists.
They have lots of built-in functions associated with them that Java doesn't, allowing you to do things like sorting and accessing a sub-list. There's also a built-in data structure called a dictionary, which is a hash.
Some mathematical operators are different.
Python does not contain the increment (++) and decrement (--) operators, but it does include exponentiation (**) and floor division (//).
Python function headers have fewer words.
A Python function header looks like def function_name(param1, param2):
There are no modifiers or variable types as in Java.