10 Steps to a Random Webpage

1. Write a function called RandomSchool() that reads your SAT.csv file and chooses a random line (but not the first line) and returns that line.

2. Write another function TotalScore(line) that adds the total of the 3 SAT scores for that random school to the end of the line, and returns that larger string.  If that school does not have any SAT scores, then just add the string ",s" to the end of the input line.  Examples:

TotalScore('02M313,The James Baldwin School ,45,421,419,394') -> '02M313,The James Baldwin School ,45,421,419,394,1234'
TotalScore('01M509,CMSP HIGH SCHOOL ,s,s,s,s') -> '01M509,CMSP HIGH SCHOOL ,s,s,s,s,s'

3. Take such a processed line of school data, and then create the HTML and print a suitable web page from it.  It should look something like:

Random School SAT Scores

DBN School Number of tests Reading Math Writing Total
02M313 The James Baldwin School 45 421 419 394 1234

4. Put your code into a file called RandomSAT.py, and run that program from your command line.  When executed, the program should print a bunch of HTML.  Add the following 2 lines to the very top of the file:

#! /usr/bin/python
print('Content-type: text/html\n')

5. Test this program a number of times to make sure that it prints out a random school each time.

6. Using FileZilla or WinSCP (or scp, if you know how), copy this RandomSAT.py to your public_html directory on moe.  Also copy the SAT.csv file to moe.

7. Log into moe, and change the permissions of the RandomSAT.py file to make it executable.  Then try running it from the command-line, and see if it produces results like it did on your laptop.  You can run the program on the command line there like so:

pbrooks@moe~/public_html$ ./RandomSAT.py

8.  NOW YOU'RE READY.  Open a new tab on your browser, and try to ask moe for your RandomSAT.py file:  http://moe.stuy.edu/~your-account/RandomSAT.py

9. In case of a problem, try to find and fix the problem using the hints in the  Conditions for Peace...

10. Write your successful URL into the Comments-to-Teacher and also submit your code to the homework server.