APCS :: Starting GoogleApp Engine - Assnmt due: Wed. June 3, in class

1. Download the google app engine stuff for your computer: http://code.google.com/appengine/
You’ll eventually need to get a google account if you don’t already have one in order to upload your applications to the real intertubes.

2. The text recommends a firefox plugin called firebug (download from here).  I recommend both using Firefox and installing Firebug.  However, it becomes more helpful the more you know about web development and various web protocols (which you don’t at this point, but you will!).  Still, it’s helpful to have.

3. ASSIGNMENT - Due: Wed. June 3:

Make bike wattage a google appengine app.  Please make it spiffy.  Here’s what I mean by that:

a. allow the user to specify any/all of the variables involved.  (Do something like have the user only fill in the variables she wants to specify, and then your code determines what’s left blank and calculate it.)

b. make it look good.  Pretty colors, clean and nice styles.

c. Explore the various elements that can be a part of the HTML form tags.  Many of the input components have several attributes and parameters that can be helpful.

3.* If you want to go above and beyond check out the examples given starting on page 93 of the text — related to Multipart POST data.  This allows you to upload plain text files.  If you do this, you should be able to upload two text files and run it through your document similarity code, and produce a number of hits between the two documents.  The hardest part about this is experimenting with Multipart POST data.  Just go slowing and print stuff out as you go.

HTML and CSS — Due: in-class Friday, May 29

We’re going to take a quick break from Python to learn some HTML and CSS.  We’ll pick python back up on Friday.

Do these assignments which were all provided by Ms. Billingsley.  Develop your html locally, and save each file into a folder.  Zip up the folder and submit it as: username.htmlLab.zip by Friday, May 29

HTML REFERENCE

  • Assignment 1: Learn some HTML
  • Assignment 2: Learn more HTML
  • Assignment 3: Learn some CSS
    3.1 Go through this basic CSS tutorial (it’s a little confusing, but just click the NEXT button at the end of each page).  Follow it up through the page that discusses applying styles to fonts.
    3.2 Use CSS formatting to reformat this html document (an interview with JK Rowling) Save it to your computer and then edit it locally. Use your new techniques of CSS styles to make the interview as readable as possible. Include colors and images if it adds to the content.

NEXT WEEK:
We’ll look at WYSIWYG editors, which do much of this work for you.  Of course, the tools are virtually useless if you don’t understand the underlying code.  If you have the time/wherewithal you can look at this assignment which uses dreamweaver.

Python 2 :: word counting

Scholars,

Your assignment is to produce the top 10 words from decl.txt.  The algorthim is this:

1.
for each word in the file
if the word does not exist in the dictionary
put the word into a dictionary with a value of 1
else
increment the value associated with the word

2.

invert the dictionary
so instead of word->count  mappings, it will contain count->[list,of,words,with,this,count]

3.

sort the keys of the inverted dictionary

print out the words associated with the 10 highest values

NOTE: this is not the only way to do this in python, but I want you to have practice doing the dictionary inversion, sorting the keys, etc.

CODE FROM CLASS

1.  The code I wrote in class…more or less, with comments

#I.O. library
import os

#open a file for reading
fp = open(”path/to/file/file.txt”, “r”)

#iterate through each line

for line in fp:
line = line.replace(”\n”,”")
line = line.replace(”,”, “”)
line = line.lower()

#line.split returns a list, so you can put it right into a loop
for word in line.split(” “):
print word

# of course, you’ll do more than print the word, you’ll add it to a dictionary with the proper count, etc.

HINTS AND ALTERNATIVES:
There is a faster way to read the file.  You can just read it all out into one big string.  That way you don’t have to go through the song and dance of processing each line.  Just do this…

fp = open(”path/to/file/file.txt”, “r”)
fullText = fp.read()
fp.close()

fullText is now a string of the whole file.

Also here is a shortcut for stripping all the punctuation except the words….

import re
fullText = re.sub(”[^a-z' ]“,”",fullText.lower())

NOTE: there is a blank space after the apostrophe (’) and before the ] in the first argument.  What this says is: “for every character in fullText.lower(), if the character is NOT a through z, an apostrophe, or a blank space, then replace it with an empty string.”

Finally, to make a list of all the words, it can be accomplished in basically one line thusly:

import os
import re

fp = open(”path/to/file.txt”, “r”)
allWords = re.sub(”[^a-z' ]“,”",fp2.read().lower()).split(” “)
fp.close()

Post AP :: Starting python

Here is a link to the official python documentation:
http://docs.python.org/

It includes tutorials, HOW-TOs, and the API.

Things you need to know for Tuesday:

1. How to run a simple python program in IDLE

2. Numerical types and arithmetic

3. String types and string manipulation methods

4. How to print and concatenate strings with numerical and string variables

5. The raw_input function, and converting string input to numerical

ASSIGNMENT:

1. Write a console based version of the Bike Wattage program.  It should ask the user for their name,  how fast they want to go V(m/s) and their weight W(kg).  Remember the formula is:

Watts = 0.276 * V^3 + 0.0686 * V * W

Lab 22 :: Catching Plagiarists - DUE: MEOM Sunday, May 10

This is the last lab assignment of APCS :(

Assignment Sheet:
Lab22_CatchingPlagiarists.pdf [If you CARE ABOUT YOUR GRADE, you'll read the assignment sheet carefully.  Especially the descriptions of each grading Milestone.]

Document Sets:

Lab 21 : Air Traffic Analysis - Due. MEOM Fri. Apr. 24

Problem Description: Lab21_RealProblems2_AirTraffic.pdf

Daily Flight Lists: Lab21_FlightLists.zip

How to read a directory of files: See HOWTO on right sidebar

What do the airport codes stand for?: Lab21_allAirports.txt

Lab 20 :: Document Similarity

We discussed Lab 20 at length in class.  Here is a copy of the problem statement I handed out….

Handout: Lab20_RealProblems1_documentSimilarity.pdf

Text Documents: http://library.ucls.uchicago.edu

AP Review I :: Litvin MC A1, A2

I will suggest some AP Review items to do for each weekend between now and the exam.

As a first suggestion for AP Review I suggest attempting one or both of the A1 and A2 Multiple Choice (MC) tests from the Litvin book.  The A test (as opposed to the AB) has the same difficulty of question as the AB just on a smaller range of topics.  The A exam basically covers everything except Data Structures, Big-Oh analysis, and the O(n*lg n) sorting algorithms.

You are all seniors and probably have your own test review strategies, but I suggest doing the following for starters:

1. Take the A1 multiple choice test untimed.

2. For questions that you feel you *should* know answer as you would in a test-taking situation.

3. If you come across a question that has a term or topic you’re unfamiliar with, research it right then, without looking at the answer key, to find the correct answer.

4. Once you finish, check your answers with the key.

5. Then repeat with the A2 test, but try to see if you can figure out the answers to questions you don’t know as you would on the test, and this time noting how long it takes you.

Lab 19 :: Ant Behavior - Due. MEOM Wed. Apr. 8

Program and watch the emergent behavior of Ants!

Assignment Sheet: Lab19_AntBehavior.pdf

There are no starting project files for this one - you can just use an existing GridWorld project to start in.  I suggest something with Critters.  You will want some images, probably.  Here are the ones I used in my simulation:

Ant:

AntHill:

Food:

Quiz 5 :: Sorting - posted

Quiz 5 is live on the moodle site.