for python 3, you have to say python3.1
http://www.python.org/download/
http://www.upriss.org.uk/python/session1.html

Use the editor idle.

idle hello.py
can run it within idle by using import or from the shell:
basics.py (1000 ways to print hello world)
bomb.py (for loops) -- find out which one is buggy
Do this by creating a file bombtest.py in idle starting with num=5
and then keep testing it as you add in more code. Why does it mess up
on Solution 4 (side effect of solution 3).

---- above is first day

name.py
convert.py -- currency
phrase.py (string analysis) -- shows functions too
cat.py
loops.py
wrongLoops.py (sanity check, can you spot the bug)
height.py
	Assignmet: ten questions ten.py
	Assignment old: piglatin
ten.py
	Assignment: Do the game of 10 questions for a number between 1 and 1000.
Is the number equal, greater than, or less than x?
People have to answer something like "it is equal to x. equal to x. exactly
x. bigger than x....."
Initially, lower bound is 1 and upper bound is 1000.
Each time you get an answer, you either raise the lower bound
or lower the upper bound.

--- above is second day

zoo.py -- arrays
simpsons.py -- dictionaries


parsingInput.py -- teaches pretty advanced stuff
filein.py
	Assignment: read in a file and repeat every line twice
	number the output lines

--- above is third day

Efficiency

Show fibfast.py and fibfastloop.py -- notion of efficiency
bubbleSort.py (comparisons & pairlooping)
mergesort.py

Assignment: best change problem
Explain but then students code
coins2.py -- for three denominations

numpyexample.py -- play with this and then compare with python looping

--- above is fourth day

randomness:

quidditch.py -- good intro to picking from a pool 
knap.py -- this gives you the basic read of the knapsack data
knapgeneticstarter.py -- give you the basic skeleton. Students should improve
knapgenetic.py -- my solution; but could get over 600

--- above is fifth day


A command line argument will deliver search results in response to that
criterion.
simplehtml.py -- opens a url

Open a web page and print it.
Works as of August 2017

From:
https://first-web-scraper.readthedocs.io/en/latest/

First:
pip install requests

ext:
import requests
url = 'http://www.showmeboone.com/sheriff/JailResidents/JailResidents.asp'
response = requests.get(url)
html = response.content
print html

Now try

pip install BeautifulSoup

python scrape.py -- a little prettier

python scrapefinal.py -- writes the file into a csv file

Assignment: Scrape the site
https://data.cityofnewyork.us/Health/DOHMH-New-York-City-Restaurant-Inspection-Results/xx67-kt59

and find all the restaurants in Brooklyn that have critical problems
and map them.




fusionsearcher.py
fusionsearcher2.py windsurfing

Assignment: A simple web search engine operating system.
Take the fusionsearcher and create a while loop
so that unless the user says he/she is done, the 
fusionsearcher  will search google and find and number each result.
It's a simple operating system because it dispatches based on input.

Maybe ask the user whether he/she liked the result.
Depending on the answer, send out a new query.
fusionsearcher3.py  
User can answer two ways: yes or no.

http://cs.nyu.edu/cs/faculty/shasha/papers/flask.zip

Download and unzip and go through the slides and the README together.
Do the examples as you go.

pip install flask



Assignment: Design a website having any functionality that you choose.
For example, an e-commerce website, a social network website,
a betting (for points, not money) website.
You will present it to class.




--- above is sixth day

Try auctionserver.py, auctionclient1a.py, auctionclient1b.py 

Alternatively, try:

Using python2.7

auctionREADMEemil
auctionclientemil.py
First human version
python serveremil.py (by default it uses bots and numbidders = 2)
and then two
python auctionhumanclientemil.py

Then switch to bot is True.
python serveremilbot.py
and then two
python auctionclientemil.py
We will have to generalize this to more later

---- machine learning
infogain.ppt
dtree.ppt

scikit_machinelearn.d:


http://cs.nyu.edu/cs/faculty/shasha/papers/scikitexamp.zip

sportsbetting_jan2016.d


For NYU Wash Sq:

Mastermind like game: guess the four numbers in order.
Each number is a single digit.
The numbers can be repeated.
Server returns number in correct position and numbers that are present
but incorrect position.
Do it for 5 positions.
Here are just the basics.
mastermindserver.py
mastermindclient.py

--- above is seventh day

For Abu Dhabi:

Statistics:
Diff2MeanSig.py	
Diff2Mean.vals
CorrelationConf.py*  CorrelationSig.py*  Correlation.vals

--- above is eighth day

For Abu Dhabi: (only if time)

dectree.py -- shows how to compute information gain etc.
Assignment:
gendata_fordectree.k 
python dectreeformerstud.py
file MakeATree.orig
target column target


--- above is ninth day


For Abu Dhabi



then auctionserver5.py auctionclient5a.py auctionclient5a.py
All you need to do is modify the function determinebid.
The idea is that players are bidding for items of
different types. The first player
who obtains all needed items while staying within budget wins.
In each bidding round, players determine a bid and send it in.
(If two highest bids are the same, then first one received gets it.)
Each player is told who received the item and for how much.
If you win the item in a round, then you pay that amount.
Otherwise, you pay nothing.
Using this information, determine what to do next. There is a comments
in the client code that say: DO SOMETHING HERE
That is what you do.
There are three versions you send: 1 vs. 1 mode.
melee mode, melee with a secret partner mode
python auctionserver5.py in one window
python auctionclient5a.py in one window
python auctionclient5b.py in one window
Start with auctionserver5.py
then the clients





Interprocess communication game.
You are given 50 units.
There are four triplets of  items.
They will come up in random order.
You will bid for items.
Whoever wins the bid gets the item
If someone gets a triplet earlier than another item, then that person wins.
So there will be a server (the auctioneer), two or more clients.
Auctioneer receives bids and tells the clients who wins or loses.

---- above is project

If you really want to suffer through nodejs,
look at:

nodejs.d/app2b.d
or 
nodejsaccessdatabase.zip

==== 

Possible final assignment: given a query with two arguments. The first argument 
is the keyword you're searching for (could be in quotes).
The second is in one of three categories: location, person, dog.
Your job is to open a web page having that keyword and an appropriate topic.
Or you return the answer -- could not find page with X category.
I will issue 5 queries.
For example:

python categoryassignment.py jemma person -- should return website
about a member of the Redgrave family

python categoryassignment.py jemma dog -- should return "could not find page with dog category and jemma as keyword"

python categoryassignment.py jemma location -- should return website 
about the Bunga river


guessing.py (binary search) -- skip
matrix2.py (matrices and movement) -- skip
gameOfLife.py -- skip


cardClass.py -- how classes look -- skip

arabic.py -- skip

arabic2.py -- language exercise. Assignment is to generalize
this as far as it will go. -- skip


Of course in our test, we will look at something other than 'jemma'

Resources that may be helpful.
Look at eliza.py and the split command.
Then the in command.
my father got angry with me

Look also at some kind of thesaurus
like http://www.visualthesaurus.com/
to get animals that are dogs, professions having to do with humans,
etc.



http://www.boddie.org.uk/python/HTML.html




german.py -- example of dictionary obsolete
simpsons.py -- example of dictionary

Assignment: an engaging Eliza program: see notes of oct 26 and oct 28 2009

discuss local and global variables.
screengame.py: print screen and print out letter; screen changes
a simple game that stops if you hit an obstacle

Assignment: game of your choosing

dectree2.py: computes entropy and conditional entropy
k dectree generates a tree in tmpinput and a result in tmpoutdectree
That works on MakeATree.orig and produces tmpoutdectree which you can show.
gendata.k can generate data for an exercise

Assignment: Determine decision tree to conclude whether sick or not 

Or better: a single person game where someone uses the arrow keys
to avoid obstacles that come from the top.
You are timed.

Sudoku game solver.

Sudokill maybe.


Need some examples of recursion
fib.py
piglatin.py
multidim.py

threader.py


From shasha@access1.cims.nyu.edu  Mon Nov 30 16:15:38 2009
Received: from mx.cims.nyu.edu (mx.cims.nyu.edu [128.122.80.107])
	by mail.cims.nyu.edu (8.13.8+Sun/8.13.8) with ESMTP id nAULFcKs007318
	for <shasha@mail.cims.nyu.edu>; Mon, 30 Nov 2009 16:15:38 -0500 (EST)
Received: from access1.cims.nyu.edu (access1.cims.nyu.edu [128.122.49.15])
	by mx.cims.nyu.edu (8.13.8+Sun/8.13.8) with ESMTP id nAULFaWO016335
	for <shasha@cs.nyu.edu>; Mon, 30 Nov 2009 16:15:37 -0500 (EST)
Received: from access1.cims.nyu.edu (localhost [127.0.0.1])
	by access1.cims.nyu.edu (8.13.8+Sun/8.13.8) with ESMTP id nAULFaKR011965;
	Mon, 30 Nov 2009 16:15:36 -0500 (EST)
Received: (from shasha@localhost)
	by access1.cims.nyu.edu (8.13.8+Sun/8.13.8/Submit) id nAULFa8w011964;
	Mon, 30 Nov 2009 16:15:36 -0500 (EST)
Date: Mon, 30 Nov 2009 16:15:36 -0500 (EST)
From: Dennis Shasha <shasha@courant.nyu.edu>
Message-Id: <200911302115.nAULFa8w011964@access1.cims.nyu.edu>
To: abk235@nyu.edu, ck1247@nyu.edu, dlc333@nyu.edu, jas1026@nyu.edu,
        jh2674@nyu.edu, lad393@nyu.edu, ld969@nyu.edu, lsl278@nyu.edu,
        mjk474@nyu.edu, msm452@nyu.edu, my719@nyu.edu, sh1759@nyu.edu,
        shasha@cs.nyu.edu, tz348@nyu.edu, yas225@nyu.edu
Subject: description of the final assignment
X-Scanned-By: MIMEDefang 2.58 on 128.122.80.107
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (mx.cims.nyu.edu [128.122.80.107]); Mon, 30 Nov 2009 16:15:37 -0500 (EST)
Content-Length: 138


Writing a program to create a decision tree based on
a set of data (called MakeATree) and you're laying out that
tree in outline format.


===== webpy, probably obsolete
Web backends 101:
*To install web.py (assuming unix or mac):*
$ sudo easy_install pip
$ sudo pip install web.py

On Windows machines:
Install easy_install:
http://www.varunpant.com/posts/how-to-setup-easy_install-on-windows
(You might need to restart your computer after messing with the PATH and
PYTHON_HOME variables for it to take effect)
$ sudo easy_install pip
$ sudo pip install web.py

On Windows machines, connect to the webpage w/ 127.0.0.1:8080 not 0.0.0.0:8080


http://cs.nyu.edu/cs/faculty/shasha/papers/webpy1.zip

Download and unzip.

cd ~/webpy1.d
Go through README

From very simple hello world, to taking arguments, to fetching from database.
All uses GET interface.

Assignment: print the input and the reverse of the input.
Also change the greeting to something more clever.

Assignment: find all information about a game having to do
with the Knicks.

http://cs.nyu.edu/cs/faculty/shasha/papers/webpy2.zip
cd ~/webpy2.d
Go through README
Show that you can go through sqlite and do all kinds of cool things.
findbet
team1='Knicks'

Here is the whole flow.
http://cs.nyu.edu/cs/faculty/shasha/papers/webpy.html
is a web page that is just static html. It uses a protocol
called CGI GET to send stuff to the server.
When the user fills in function and argument and clicks submit
(please look at the code of webpy.html) the base href 
http://0.0.0.0:8080 has that function information added to it.

Now looking at server.py in the class index GET function,
 the line
        postquestion = web.input(name=None)
gets that function and arguments and dispatches to the appropriate
python function which in turn accesses the database.

In particular, render.index(findbet('='.join(namefields[1:])))
causes the result of findbet to be put on the index.html page
in the templates directory.
The fact that it's index.html is determined in the urls = statement
towards the top.

If you look at templates/index.html, you can see how information is passed
from the findbet function (or other) to the $name variable.
I'm a little baffled by how to format things better.


