| Course:
CS 140 Location: 224 Johnson Hall Times: Tues/Thurs 8:30-10:00 TA: Nancy Decker (nkdeck07) |
![]() |
Lisa
Torrey (ltorrey) Office: 106 Bewkes Hall Hours: Wed/Thurs 3:00-4:00 TA hours: Thurs 7:00-9:00pm |
| About | Work | Policies | Python |
| 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
both
challenging and rewarding, and it requires both technical precision and
creative design. 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. |
| Project Description |
|---|
| 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. Deadlines
Ideas for topics
You don't have to use one of these ideas-- you can propose an idea of your own as well. If you are using pygame in your project, you will need to install the pygame library from here and check out this tutorial. |
| Current coursework |
|---|
|
Tuesday, December 8: Web search. Class examples: web_crawl.py, capital.py
Thursday, December 3: Webpages and HTML. Class example: webpage.html
Tuesday, December 1: Security. Class examples: break_caesar.py, permute_cipher.py, good_password.py
Thursday, November 19: Bioinformatics. Class examples: make_dna.py, find_pattern.py, find_snp.py
Tuesday, November 17: Artificial Intelligence (AI). Class examples: tictactoeAI.py
Thursday, November 12: Computer games. Class examples: tictactoe.py
Tuesday, November 10: Human-computer interfaces (HCI). Class examples: coordinates.py, drops.py, graphical_convert.py
Thursday, November 5: Computer graphics & animation. Class examples: falling.py, snowfall.py, growing.py, tunnel.py
Tuesday, November 3: More graphics in Python. Class examples: stoplight.py, face.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 20: Sorting. Class examples: filesort.py, compare_sort.py
Tuesday, October 13: File input and output. Class examples: files.py, wordcount.py
Thursday, October 8: Searching. Class examples: search.py, new_months.py, compare_search.py
Tuesday, October 6: Lists. Class examples: months.py
Thursday, October 1: Functions. Class examples: functions.py, probability.py, findprime.py
Tuesday, September 29: Review and practice for the exam tonight at 7pm in Bloomer Auditorium.
Thursday, September 24: Review and practice. Class examples: coinflip.py, testprime.py
Tuesday, September 22: Loop statements. Class examples: username_best.py, annoying.py, new_average.py
Thursday, September 17: If statements. Class examples: new_greeting.py, new_convert.py, username_better.py, guess.py
Tuesday, September 15: Programs with strings. Class examples: username.py, backwards.py, savings_better.py, vowels.py
Thursday,
September 10:
Programs with
simple loops. Class examples: power.py,
average.py,
savings.py
|
| Course policies |
|---|
General
|
| Academic Integrity |
|---|
Your student
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 |
|---|
| Ideally, programming
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
when
you're working with others. The very real possibility of
these
benefits is the reason I do encourage collaboration on homework.
To get the benefits, though, you have to go about
collaboration
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. |
| Python |
|---|
The official Python website
is the definitive source for information, but below are some
quick-reference guides.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. |