Updates | Course Schedule and Calendar | Course Material | TAs | Grade Distribution | Assignments | Robots and Garments | Course Info and No-Cheating Policy | Top of page
Dr. Grace Ngai, PQ 826, 2766-7279, csgngai _at_ polyu.edu.hk
Lectures:
- PQ604A,B Monday 9:30-12:30
- PQ604A,B Tuesday 9:30-12:30
- PQ604A,B Friday 9:30-12:30
Weekly Quiz: Thursday 11:30-12:30, PQ604A/B/C
Welcome to COMP 201 -- Principles of Programming, or, as I often argue that it should be named -- Introduction to Programming. We do not assume any prior programming knowledge in this course, we're here to help you get started with this very crucial skill that will carry you through the rest of your courses here in the Department.
Because of the size of this class, I have divided it into three sections. For the sake of consistency (I do not guarantee that all the sections will be going at the same speed), I would request that you not skip between the sections; though if you are unclear on some concept and feel that you could benefit from hearing the material a second time, do feel free to attend more than one section.
Updates | Course Schedule and Calendar | Course Material | TAs | Grade Distribution | Assignments | Python | Robots and Garments | Course Info and No-Cheating Policy | Top of page
This is where all the official announcements will be posted. Keep an eye out and check this page frequently for the latest information.
- Nov 22 2009: We have two more quizzes to go. Just like Quiz 9 (the cancelled quiz), both of the upcoming quizzes will have grade guarantees -- that is, if you complete certain levels, you are guaranteed a certain grade for your continuous assessment part of the course. In other words, it's a one-shot chance at a grade. You can expect, however, that the next two quizzes will be substantially more challenging than Quiz 9, so work hard!.
- Nov 20 2009: As you all know, we had some network problems during the quiz yesterday, which affected many of you. In view of fairness, we have decided to cancel yesterday's quiz, so in total, we will have 10 quizzes instead of 11.
- Nov 20 2009: Here is the last quiz and the data for it.
- Nov 17 2009: Documentation for the graphics module that we used in class can be found here: http://mcsp.wartburg.edu/zelle/python/graphics/graphics/index.html
- Nov 16 2009: About the Morse Code Generator webpage for robot assignment 5: It is workable only on Mozilla Firefox, apparently. So if you are using IE, download and install Firefox and the page should work for you.
- Nov 16 2009: The question paper for Quizzes 5-8 are available for your practice.
- Nov 10 2009: The last two robot/garment assignments and the second-last programming assignment have been released.
- Nov 9 2009: The slides for Objects and Graphics have been released.
- Nov 4 2009: I want you to do some homework before the next class. Please go home and revise your statistics. In particular, I want you to know how to calculate the mean and standard deviation of a list of numbers. You might also want to think about how you would calculate those statistics using a Python program.
- Nov 2 2009: One announcement about the robot/garments assignments: you may not use any outside modules. The pyRobot module (and the built-in Python modules) should be the only ones that you are using.
- Nov 2 2009: I have updated the stats and feedback for Quiz 6 to include the full set of concepts tested in Question 2.
- Nov 2 2009: Sorry for the delay -- COMP 303 midterm this week turned my whole schedule upside down... slides for data collections are out.
- Oct 30 2009: Statistics and overall feedback for Quizzes Q4, Q5 and Q6 are out.
- Oct 30 2009: We have updated the iCATch Reference Document with the range of valid readings from the ultrasonic, IR, light and touch sensors. You can safely ignore any readings that fall outside the range that we have given.
- Oct 20 2009: Added an update to Robot/Garment assignment 4 for robot groups. Search for the string "20/10/2009".
- Oct 20 2009: For practice purposes: here are the Quizzes 1-4
- Oct 19 2009: Robot/Garment assignments 3 and 4 have been released.
- Oct 14 2009: More information about programming assignment 2: The definition of a line is a sequence of characters that is terminated by "\n" (the newline character), and not a line as it appears on the screen. The latter is dependent upon screen and window size and thus is not reliable.
- Oct 13 2009: Two things about the robot/garment assignments
- You need to hand in one assignment per group (but make sure that one of you hands it in.
- At the end of the semester, we will give some extra credit points for nice-looking garments or robustly-working robots. For the time being, the appearance of your garment or your robot won't win you any extra points (but then again, please don't make it look too horrible!)
- Some of you are having some trouble with the sensors, so we wrote up a frequently-encountered problems list
- Please take care of your robot and your electronic components. Of course there will be problems, but when your group keeps on killing component after component -- at some point, the problem isn't with the electronics any more, it's with you. We reserve the right to charge you for damages, if it happens too often. Make sure that your sensors are plugged in firmly BEFORE you attach the battery.
- Oct 12 2009: More information for the robot/garment demo on Thursday:
- We will have two bridges set up for you guys to calibrate the light sensor values from. You have 20 minutes to test your program and to get the current light sensor values.
- You may not change the program that you handed in. If your program requires that you input a new light sensor value to start running, you should use a variable to store that data, and use input() and eval() to give your program the needed information.
- When you demo your program, you will be the one to place the robot onto the bridge.
- Oct 12 2009:Some clarification on question 2 of the programming assignment:
- The definition of a word is: a sequence of non-whitespace characters. Whitespace includes begin-of-line and end-of-line. For example, if we have a line: "A BC D", it would have 3 words in it. You do not need to worry about whether your words make sense.
- The definition of a character is: Anything that you can type in on the keyboard and stored into the text file. This includes newlines (which are the character "\n") and whitespace. Blank lines are considered to be one line.
- Some sample data for you: the file asgn1.html contains 102 lines, 852 words and 5143 characters. The file asgn2.html contains 57 lines, 446 words and 2816 characters.
- Oct 12 2009: Assignment 1 and Quiz 3 have been graded, you can take a look at the overall comments. Assignment 1 and Quiz 3.
- Oct 11 2009: The lecture notes for Conditionals and Loops have been released.
- Oct 11 2009: The signup sheet for the robot demos is posted outside Simon's office at PQ713. The rules for the robot assignments are:
- The code for the assignment must be handed in on WebCT by 7am that morning.
- The demo will be on 15 October, from 16:30-20:30.
- You will run the demo on the lab machines (we will prepare Bluetooth adapters for you). To prepare, you must show up at the demo room at least 20 minutes ahead of time. You will be given the program that you handed in to WebCT and you have 20 minutes to set up your program and robot.
- Each group has 5 minutes for their demo. All students in the group must be present, the TAs may choose to question anybody in the group about their code. If the student fails to answer satisfactorily, or the task for the demo cannot be finished within the 5 minutes, then we reserve the right to grade accordingly.
- Oct 10 2009: Clarification on the second programming assignment: For question 1, you can assume that only alphabetic characters (a-z, upper and lower case) are in the string. For the second question, the file may contain any characters that you can type on the keyboard. A word is defined as something that's space-separated (i.e. this sentence has 14 words).
- Oct 7 2009: The second programming assignment has been released.
- Oct 7 2009: Some of you had trouble handing in your assignments. Since this is your first assignment, we will accept late handins, but we will take off points for being late. But this is the last time we'll do this. Starting from the first robot assignment on, we will no longer accept late handins. You have been warned.
- Oct 5 2009: There will be a quiz this Thursday. Coverage: Everything up to Slide 17 on the Strings chapter. (Just before "Python Data Types")
- Oct 2 2009: One more clarification: for the garment students, the obstacle will be a solid block that covers the whole area from neck to waist (so you don't need to guess at where it is).
- Oct 2 2009: While I was at it, I also added in a few more sample runs of the approxSqrt.py assignment for you.
- Oct 2 2009: It seems that some people are making the Pi approximation question in the assignment more complex than it needs to be. So, in response to a question I got in class this morning, I taught Section 3 how to do that particular question. To be fair, I've also updated the assignment page to include what I told Section 3 this morning. Check it out if you are having problems. By the way, you are NOT to use the general formula for the approximation of Pi. Use loops.
- By the way, for that question, when I ask you to sum up n terms, I want n values in the formula. For example, suppose that n = 10. Then your formula should be: pi = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + 4/13 - 4/15 + 4/17 - 4/19. Some of you are misunderstanding that the maximum denominator should be n. That's not what I meant.
- Oct 2 2009: Some of you were asking me about the robot/garment assignment. I have updated the skeleton of the program (the remote-controlled one) to give you more hints. Go and redownload a copy of the program skeleton and take a look.
- Sept 29 2009: Most of you have gotten your Quiz 2 back. You can take a look at the overall feedback.
- Sept 29 2009: I've updated the contact information for Simon (our tutor), in case you need to hunt him down.
- Sept 26 2009: The slides for Functions have been released.
- Sept 26 2009: The two robot assignments that have just been released will involve a concept that I plan to cover this coming week. Just in case any of you guys are motivated to start working early, you can pre-read Chapter 7.1 of the Python book and the notes on Simple Decisions.
- Sept 25 2009: Robot Assignments 1 and 2 have been released.
- Sept 25 2009: Programming Assignment 1 has been released.
- Sept 22 2009: We added one more function to the Robot and Garment API (everything else is unchanged, we just added one more function -- getTouchSensorPressed() -- to allow you to wait for the touch sensor to be pressed). So please re-download a copy of the pyRobot.py module and replace your old copy. The iCATch API has also been updated.
- Sept 22 2009: We've finished grading Quiz 1. As I said in class: relatively little programming-related problems. You can take a look at the overall feedback.
- Sept 19 2009: Roy and Simon have put together a document with hints on making your robot/garments work. Check it out if you have any problems!
- Sept 19 2009: Reminder: There will be a quiz on Thursday. The coverage of the quiz will be everything up to and including Slide 24 on the "More Python" lecture.
- Sept 19 2009: The lecture notes for basic loops and strings are out
- Sept 19 2009: I set Sections 2 and 3 a practice exercise in class so I think that to be fair, I should release it here for Section 1 as well.
- Sept 16 2009: The extra files for Python are now ready for download. Check the Python subsection
- Sept 15 2009: Because of the T8 signal, this morning's classes will be cancelled. However, because the other two sections will still have class this week, we need to make up the lecture so that the sections are synchronized (somewhat). Therefore, Section 2 students: please go to Friday's section. I have already booked PQ604C as well, that should be enough to hold you all.
- Sept 14 2009: Reminder: there will be a quiz this Thursday. Since there are so many of you, we have booked the PQ604 and PQ606 labs for this quiz and we'll divide you up among the rooms:
- Students with last name from AU-CHAN: Line up outside PQ606
- Students with last name from CHAU-LAU: Line up outside PQ604A
- Students with last name from LAW-SZETO: Line up outside PQ604B
- All other students: Line up outside PQ604C
The TAs will check your student ID and direct you to your seat.
- Sept 14 2009: The FINAL list of robot/garment groups has been released. There were 8 of you who couldn't be bothered to show up for today's group facilitation session. You have been randomly divided up into groups. Please check and contact your group partner, and sign up for a slot in the extra lab sessions!
- Sept 12 2009: The most updated list of robot/garment groups has been released. Some of you still aren't in a group yet. To help you to form a group, we're calling a meeting for all non-grouped students on 14th September, Monday, at 12:30pm, in PQ604B. There're an even number of you left, so you'll be sure to be able to find somebody. If you don't show up for that meeting, you will be randomly assigned to a group.
- Sept 12 2009: Correction: the scheduling conflict for next Friday's extr lab session only affects the robots. The garment session will start at 4:30pm as previously planned.
- Sept 10 2009: Due to a scheduling conflict with the TAs, the extra lab for robot/garments next Friday will be moved back one hour, to start at 5:30pm instead of 4:30. Please note.
- Sept 9 2009: To help you to get started with the robots and the garments, we will be having two additional lab sessions during Week 3. These sessions are there to introduce you to the components and also get you started with your robot or your garment. Please sign up for one of the slots on the signup sheets outside Roy's office in PQ730 (first come, first served).
- Sept 9 2009: For those of you who haven't formed groups yet to work on the robots or on the garments -- the robot groups are all full, and the quota for 3-person groups is also full. Therefore, any new groups forming will have to work on garments, and also have only two members. In addition, some of you who chose to work on robots got moved to work on garments. Here's the latest group information.
- Sept 9 2009: In class, we're telling you to save programs onto your J: drive, which is like your own personal network drive. Here's how to access your J: drive from home. (You may need to log on with your COMP UNIX Password -- ask the Tech Team if you don't know what it is.)
- Sept 5 2009: Lecture notes for Week 2 have been posted. Not sure if we'll be able to get that far, but it's probably best to let you guys have them just in case.
- Sept 4 2009: The HOWTO for the robots and the garments have been released. Maybe this will help you to decide whether you're working on a robot or on a garment.
- Sept 4 2009: Some of you were asking (and I suppose most of you are wondering) about this: no, making the robots will not involve any kind of soldering, or turning screwdrivers (well, not much of that anyway), or any other kind of really difficult mechanical controls. We're the Department of Computing, not Mechanical Engineering! Similarlly, the garments won't require you to use sewing machines, or even needle and thread, if you don't want to. If you would like to make a really nice vest for yourself, that's great, but otherwise, double-sided tape will work fine (and I should think all of you know how to use that!)
- Sept 4 2009: The venue for the lectures have been changed to PQ604B by request of the technical team.
- Lecture notes for week 1 have been posted.
- First week arrangements: Section 2, Tuesday 10:30am-12:30pm, PQ604A; Sections 1 & 3, Friday 9:30am-12noon, PQ604A & B
- Section divisions have been released. Please check which section you belong to.
Updates | Course Schedule and Calendar | Course Material | TAs | Grade Distribution | Assignments | Python | Robots and Garments | Course Info and No-Cheating Policy | Top of page
Updates | Course Schedule and Calendar | Course Material | TAs | Grade Distribution | Assignments | Python | Robots and Garments | Course Info and No-Cheating Policy | Top of page
We're going to be following a textbook, Python Programming: An Introduction to Computer Science, by John Zelle. It's an excellent text, but there are two problems with it:
- It's fairly expensive. Amazon.com lists it for USD34.20.
- It uses a recently-outdated version of Python, our programming language. Python 3.0 was released only earlier this year, and the authors haven't come out with a new version of the book yet.
However, there's some good news. Google Books (go Google!) has a FREE copy of the book online! You are strongly encouraged to use that version, and you will find that my lecture notes follow the book chapter fairly closely, with two caveats:
- Due to copyright reasons, Google does not put the whole book online, some pages are missing here and there. However, it's good enough for our purposes.
- The book is using Python 2, and we'll using Python 3. Therefore, you will find differences between my slides and the book every now and then. You should be able to figure out what version something belongs to, but if you are in doubt, ask. You can also use the official list of changes between Python 2 and Python 3 as a reference (but that document's very technical, if you don't understand it, forget it).
Lecture notes will be available latest by Sunday midnight for the following week's classes. I would strongly suggest that you print out your own copy of the notes and bring them to class.
- Objects and Graphics
- Data Collections
- Loops and Booleans
- Conditions
- Functions (without animations) and Functions (with animations, 104 slides!)
- Simple Decisions
- Strings
- Basic Loops
- IO and Data
- Introduction to Computing
- Introduction to Python
Updates | Course Schedule and Calendar | Course Material | TAs | Grade Distribution | Assignments | Python | Robots and Garments | Course Info and No-Cheating Policy | Top of page
Our TA for this course will be Simon Lui (email: csshlui _at_ comp.polyu.edu.hk). In addition, we also have some support from Roy Ho, our department's instructor. Roy's office is at PQ730 and Simon's office is at PQ713. You can feel free to hunt them down and ask questions about the coursework, but please remember the following:
- They are supposed to help you with the work, not do it for you;
- Please be respectful of their time. Both Simon and Roy have other large classes to support, so you can imagine how busy they are. In any case, it is good for you to try and solve your problems first, rather than running to them all the time.
Updates | Course Schedule and Calendar | Course Material | TAs | Grade Distribution | Assignments | Python | Robots and Garments | Course Info and No-Cheating Policy | Top of page
The grade distribution for COMP 201 is as follows:
| Continuous Assessment | 60% |
| Final Examination | 40% |
Please note that you need to pass both the continuous assessment and final examination components in order to pass the course.
The continuous assessment portion of COMP 201 will be made up of assignments and quizzes. The assignments will be divided into regular programming assignments as well as robot assignments. The grade distribution is as follows:
| Regular Programming Assignments | 15% |
| Robot Programming Assignments | 25% |
| Weekly Quizzes (best of 10) | 60% |
Updates | Course Schedule and Calendar | Course Material | TAs | Grade Distribution | Assignments | Python | Robots and Garments | Course Info and No-Cheating Policy | Top of page
Assignments will be posted here as they are released.
- Programming Assignment 3 (due 07:00, Monday November 23rd)
- Robot Assignment 6 (due 07:00, Thursday December 3rd)
- Robot Assignment 5 (due 07:00, Thursday December 3rd)
- Robot Assignment 4 (due 07:00, Thursday November 5th)
- Robot Assignment 3 (due 07:00, Thursday November 5th)
- Programming Assignment 2 (due 07:00, Monday October 19th)
- Robot Assignment 2 (due 07:00, Thursday October 15th)
- Robot Assignment 1 (due 07:00, Thursday October 15th)
- Programming Assignment 1 (due 07:00, Monday October 5th)
- Assignment 0 (due 23:30, Friday September 11): Signups for Robot/Garment Groups
Updates | Course Schedule and Calendar | Course Material | TAs | Grade Distribution | Assignments | Python | Robots and Garments | Course Info and No-Cheating Policy | Top of page
Simon has written up a very good tutorial on how to install Python, how to install JEdit, a program editor, and how to run Python.
The programming language that we will be using in COMP 201 is called Python. Python is a scripting language that used in the real world (for example, the microblogging service Twitter uses a lot of Python), but it is also syntax-light enough that it is very suitable as a first language. We have discussed the merits of using different languages at length, and finally it was decided that Python would be suitable to give students the general idea of programming, first, before going into more syntax-heavy languages such as Java and C++.
Python is free for download, and I would suggest that you download and install it on your home computer, so that you can practice at home. You can either grab it directly from the official Python download page (make sure you get Python 3.1.1, not Python 2), or use the links below:
After you install Python onto your home computer, then you need to download a few more things to get your programs to work. First of all, we have the graphics library:
You need to save that file into the Python library where all the other Python modules are, so that Python will know where to find them when you import them. The directory for the library is:
- If you're using a Mac, move them to "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1"
- If you're using Windows, you move them to "C:\Python31\lib\" (or the lib subfolder of wherever you installed Python to.
The other modification that you need to make to your Python library is for the robots and the garments. However, for this one, we need to apologize to Mac users -- right now, we don't have libraries that support the Mac yet (yes, I know, it sucks, I use a Mac too!), so you will have to borrow a friend's PC, or install a virtual machine running XP. For the rest of you, here are two more files that you'll need:
pyserial is an executable. When you have downloaded it, double-click it to execute. It will ask you where you installed your Python. Type in the directory, and it will do the rest of the work for you.
pyRobot.py is a Python module. Save that into the same place as you saved the graphics.py file.
Updates | Course Schedule and Calendar | Course Material | TAs | Grade Distribution | Assignments | Python | Robots and Garments | No-Cheating Policy | Top of page
In addition to the usual programming assignments and quizzes, some of your assignments are going to be done on things that move -- robots and clothes. We're going to divide you all up into groups (that's your assignment 0), and each group will have either a robot or a vest to work with. You will get some motors or lights, and some sensors that "see" or "feel", and you'll use them to make your robot/vest do stuff.
The robot and the vest use the same set of electronics, and the assignments will be as similar as possible. You can check out a reference document for the electronics modules and see what's available and how to use it, as well as a quick rundown of the assignments that we'll going to be doing on the robots/garments.
Updates | Course Schedule and Calendar | Course Material | TAs | Grade Distribution | Assignments | Python | Robots and Garments | No-Cheating Policy | Top of page
This is potentially the most serious issue in this course. COMP 201 has
a no-cheating policy, which means that all instances of cheating will be
severely dealt with.
Here is the no-cheating policy in COMP 201:
On programming assignments:
- You may discuss the idea with other students, or, in the case of group projects, other groups. However, keep your discussions to high-level concepts. You are to work on your code alone.
- You are NOT to share or discuss your code with anybody. That includes showing anybody, excepting myself, or your TA, the code.
- Similarly, you are NOT supposed to help other people with their code.
On Quizzes:
- Each Quiz will last for 50 minutes.
- All quizzes will be closed-book, closed-notes.
- After the quiz questions have been handed out, you will be given 5 minutes during which you may discuss the quiz questions with your classmates. Two rules apply during this phase of the quiz:
- You may NOT leave your seat during this time.
- You may NOT write or type anything down. You have to remember everything in your head.
- You may NOT start writing any code.
- Nobody is allowed to enter the labs during this time. Latecomers, or anybody who has to leave the lab for any reason, will have to wait outside the lab until after the 10 minutes are up.
- After the 5 minutes are up, you will be given the remaining 45 minutes to work on the quiz questions. You are to work alone during this portion of the quiz.
Anybody who breaks any of the quiz rules will be disqualified from the quiz immediately for a first offense. Subsequent offenses may result in failure from the course.
For examinations, I am assuming that you know what it means to cheat. If you didn't know that already, please come and talk with me. Students found cheating in examinations will have to face the university disciplinary council -- at the very least, the penalty will be failing the course; at the worst, it could result in expulsion.
If a student is found cheating in programming assignments (for example, if we find that he copied code from another student):
- For the first offense, the student will automatically be
assigned a zero score for that particular assignment. The
penalty will be applied to both the one who copies the work and
the one whose work is being copied.
- For subsequent offenses, the students concerned will get a one-grade downgrade in their continuous assessment grade. Therefore, Bs will become Cs and Cs will become Ds. Again, this applies to both the copier and the one who let his/her code be copied.
Special warning --- A software package will be used to scan the
programming assignments that the students have submitted. The software
is capable of identifying copied assignments, even if the persons
concerned have made superficial modifications to the code. You have
been warned.