Introduction to Computer Science - 2

Spring 2015 -- Peter Brooks

Interesting projects Some (not all) of the best, eye-opening projects
Projects due Mon, June 8, midnight On the homework server's Project slot, enter the following things into the Comments to Teacher (both partners must, if duo)
  • What is the state of the project: what works, what doesn't, what to avoid because it crashes, etc.
  • If working duo, who was your partner and who did what?  (if solo, say so).
  • A clickable link to the project.
  • Pack up all your files (.HTML, .PY, .CSV, etc.) into a .ZIP file, and submit that file along with the comments above.
Dictionaries Here's an Idle shell session defining and querying dictionaries
Project Proposals due Tues (5/19) midnight
I need to know whether you'll be working on it solo or duo, and if duo with whom.  If duo, both of you need to submit the (hopefully similar) proposal. What will the user need to do on your interactive web pages (answer questions -- like what?, answer survey -- about what?, etc ).  What kind of answers/results will you provide?  Will there be continuing interaction with the same user?  Creativity will be part of your assessment.  Either write your description into the Comments-to-Teacher or submit a file (.doc., .docx, .txt or .pdf only).
Here's how to access the web using Python commands  
Homework for Thurs, 5/7 Here is the set of query/answer exercises...
Thurs, 4/30: I shall return (tomorrow).  In the meantime, let's prepare for attacking the SAT data... Class exercise: create the function ExtremeScores(which_column, how_many, is_top), which will print out (not return) the top (or bottom) scores and the schools which have them from the SAT student file.  The argument which_column should be the number 3 (for Reading), 4 (Math), 5 (Writing) or 6 (Total, which you'll have to calculate).  how_many should be the number of schools, and is_top should be True if you want the highest scores, and False if you want the lowest ones (ignoring schools with "s" as data). For instance, if I wanted the bottom 3 scores in Writing (which_column = 5), then ExtremeScores(5,3,False) would print (I've added commas between the printed columns -- don't worry about doing that if you don't want):
Writing Mean , School
285 , International School of Liberal Arts 
291 , HIGH SCHOOL OF WORLD CULTURES 
296 , Kingsbridge International High School 

(Of course, now you can finally find out which school has the highest SAT scores in each of the categories and the total...)

Starting Query/Answer interaction
1. In the class exercise below, you used my Python program FormEcho.py to display the values that the user typed into you query form.  Take a look at the
FormEcho.py program.  We'll go over how it works.
2. Here's a small SAT query page that the user can interact with.  This is the direction we're going in.
Class exercise
Create a web page (called TryInputs.html) and put it into your public_html folder.  Try to create each type of form input element on the page (and try to format them nicely).  Use the following form tag:
<form method="GET" action="http://homer.stuy.edu/~pbrooks/FormEcho.py">
and test your web page by going to http://marge.stuy.edu/~your.account/TryInputs.html
Here's a page of documentation on Web-Python Interaction  
Here is 2010 SAT student data for NYC schools.

Here's the sample student grade data file that we'll use in class (right-click to download)
Here's the mysterious disappearing homework, due Mon, 4/27, midnight.
Extra challenge problems with anagrams are here.
There's a homeword slot for these challenge problems, but they're all optional and there's no real deadline.
Homework exercises on large lists, due Mon, 4/20, midnight.
The exercises are here.  You'll be using the English wordlist in the file "dictall.txt" mentioned below.  Download it.
File reading/writing
Here's a big file: a huge list of English words (feel free to download it).
More advanced Python list constructs (will not be covered on Wed's test)
Here are many different answers to Codingbat's List-2 exercises -- compare your answers to these...
And here is a mini-tutorial on Python's "list comprehensions" and the reduce() function.
Test on Wed (4/1) 
Everything about Python that we've covered including string and list methods (at least those on the Python cribsheet).
List homework, due Sun, 3/29 midnight   Here are my answers to the homework.
String homework, due Sun, 3/22 midnight
Answers are here.
Popular Python built-in functions
Here's a wonderful site showing a list of the popular (frequently used) built-in Python functions (really: "methods").
FINALLY, the class homepage competition!  (Homework, due Sun, 3/22) Here is the Great Homepage Competition page. The rules are at the bottom.  It's a homework requirement to vote (for both first and second place) among the entries for your class only.  A lot of you put a lot of effort into these pages and I congratulate you, they're great.
Loops and Strings homework, due Tue, 3/17, midnight Go to CodingBat, log in (you should already be registered using the instructions below), and complete all the (only 6) exercises in Python String-2.  Most if these have to do with finding particular patterns inside strings -- a very useful skill to develop when having the computer read through text.
Python & HTML homework, due Sun, 3/8 midnight Here are the exercises and instructions.
New version of your homepage, due Wed. 3/4 midnight. Many of you created quite fancy personal homepages for the assignment. That's great. But to accomplish that, many of you borrowed significant sections of CSS and/or Javascript code, which you copy/pasted (with perhaps minor modifications) into your HTML file. That's fine. But the assignment did require you to cite where you got the code from. And I saw very few citations.

So....

To complete the NEW assignment:

  • Create a link on your homepage (or if you have many pages, then the main page), called "Citations"
  • That link should take you to another page that you create that details where you obtained any pieces of code from. Explanations are welcome about how you made use of thos e pieces or modified them.
  • This little page need not be fancy -- it's the content that's important.
  • If you got nothin from noplace (not easy to do), then simply say so on that citations page.
  • There is a homework server slot for this new version (due Wed 3/4 midnight). You'll probably be submitting the exact same link as you did for the previous version, but we'll see your marvelous homepage with the "citations" link on it. Please make sure that you don't just copy the URL into the Comments-to-Teacher, but make it a clickable link using the <a> tag -- be sure to put the URL inside double-quotes.

It is this modified version of your homepage that will be placed on our public link page (for the class competition or just general viewing).

Python cribsheet This is a compact reference sheet for all of the concepts that we'll cover in Python.  The sheet will be provided to you during every Python test/quiz.  There's more to Python than what's on the sheet -- in particular, there are very many libraries that one can import into Python.
Monday, March 2. I'm sick with a cold.  Here are some tasks:
1. Check your homework entry on the homework server, in case I left a comment or detected a problem with your homepage homework.
2. Register at CodingBat (below).
3. Try to do the following exercises in the Python section of CodingBat: diff21, near_hundred, sum_double.
CodingBat (Python) is here. Please do the following:

Register an account with CodingBat so that you have your own ID (a email address) and password.  Afterwards, set your preferences (the "prefs" tab at the top-right of the main screen) in the following way:

When asked for your last and first names, put instead this year (2015), the word "intro-2", your period, followed by your last and first names, all separated by commas.  For instance, if your name is Fred Earwig and you're in Period 6, put (with no spaces):  2015,intro-2,Period6,Earwig,Fred
  1. In the "Share To" box, put: products@micromind.com.  No, you're not going to be sent spam -- it's just a old email address I happen to use for such purposes.
Python! Download, install and run Python for the first time from here NOTE: we will be using version 2.7.9, NOT 3.4.x so make sure to download the right version.  In order to download the correct version, you'll need to know whether you're running a 64-bit or a 32-bit version of your operating system (Windows or Mac OS).  For Windows, here's a website that will tell you.  For the Mac, here's a page that should guide to the answer.
Personal Homepage homework, due Sun, 3/1, midnight Create a homepage, about you or one of your interests. The goal is to make it creative and interesting.  Call your html file: homepage.html.  Feel free to get ideas from anywhere. If you borrow code from anywhere, you must cite it PROMINENTLY on your page -- if you want to borrow (steal) an idea, understand how it works first. 

Copy (upload) your homepage to Lisa or Marge, into your public_html  directory there.  Also upload any personal pictures/files that it refers to, and any other webpages if you've created a set of them.  Once you've done that, your homepage will be accessible to the world at the address: 
http://lisa.stuy.edu/~your_account/homepage.html

TEST YOUR PAGE -- make sure all the pictures and links work.

Then, create a link to the page in the Comments-to-Teacher of the homepage slot on the homework server.  Also indicate, in the same slot, which category you want to put your page into:

  1. enter it into the class competition (recommended)
  2. make it visible to other class students, but not in the competition
  3. private (seen by Mr. Brooks only)

After submitting your link and other text to the homework slot, go to View Homework to test whether the link actually works.

Other languages (CSS and Javascript) in your HTML file.  
Colors in HTML (and CSS)  
HTML homework #1, due Sun. 2/15 midnight.
You should create an HTML page on your home computer that looks somewhat like this.  It has to have a table, at least an embedded picture, and at least one link.  Upload this html page to your public_html directory, and put a link to it in the Comments-to-Teacher box of the homework slot.  Instructions on how to do this are here: Uploading to Stuy.  After you have done so, go back to the View Homework menu option, and try clicking on the link you've submitted to me.  If it works, you're fine.  If not, fix it -- I do not want to click on your link and see nothing, or some error message.
Add to the class Documentation Resources page Y'all have been invited to edit the class Documentation Resources page.  Add the documentation that you found to the table by adding a new row at the bottom.  If you've found the same resource as a previous contributor, add a row anyway with your own comments.
First task: fill out your Profile on the Homework server.
  1. Go to the main class link page (http://www.micromind.com/stuy)
  2. Click on the Homework/Grade server link
  3. Choose the Profile menu item
  4. Choose your period and name
  5. Log in with your 4-digit Stuy ID as your password
  6. Fill out your email address, home phone #, and preferred first name only, DO NOT CHANGE YOUR PASSWORD YET.
  7. Save: (Change Profile button)...
  8. (optional, but recommended): now you can change your password for this Homework server, if you want.
  9. REMEMBER this password!
Help from Mr. Brooks Feel free to come and see me during periods 2, 3, 6 or 8 in room 301 or, by appointment beforehand, just after school also in room 301.
Sending email to Mr. Brooks:
1. Use the correct address in the right-hand box
2. You MUST include your name in the subject line or body of the message, otherwise I won't know who it's from.
Period 7: intro-s15-7@micromind.com

Period 9: intro-s15-9@micromind.com

Period 10: intro-s15-10@micromind.com

Stuyvesant bell schedule  
Homework/grade server  
Support Wikipedia