[
  {
    "path": ".directory",
    "content": "[Dolphin]\nPreviewsShown=true\nTimestamp=2013,9,6,11,48,45\nVersion=3\n\n[Settings]\nHiddenFilesShown=true\n"
  },
  {
    "path": "Python2/ex01.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex01: A Good First Program\n\nprint \"Hello World!\"\nprint \"Hello Again\"\nprint \"I like typing this.\"\nprint \"This is fun.\"\nprint 'Yay! Printing.'\nprint \"I'd much rather you 'not'.\"\n# print 'I \"said\" do not touch this.' \nprint 'This is another line!'\n"
  },
  {
    "path": "Python2/ex02.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex2: Comments and Pound Characters\n\n# A comment, this is so you can read you program later.\n# Anything after the # is ignored by python.\n\nprint \"I could have code like this.\"  # and the comment after is ignored\n\n# You can also use a comment to \"disable\" or comment out a piece of code:\n# print \"This won't run.\"\n\nprint \"This will run.\"\n"
  },
  {
    "path": "Python2/ex03-new.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# Find something you need to calculate and write a new .py file that\n# does it.\n\n# integer\nprint 50 * 2\nprint 1/500\nprint 4 * 3 - 1\n\n# float\nprint 3.14 * 2 * 200\nprint 1.0/20\n\n# The following expressions are more complicated calculations.\n# Ignore them if you haven't learned anything about each type.\n\n# decimal: more accurate than float\n# import decimal\n# print (decimal.Decimal(9876) + decimal.Decimal(\"54321.012345678987654321\"))\n\n# fraction\n# import fractions\n# print fractions.Fraction(1, 3)\n# print fractions.Fraction(4, 6)\n# print 3 * fractions.Fraction(1, 3)\n\n# complex\n# print(1j * 1J)\n# print(3 + 1j * 3)j\n"
  },
  {
    "path": "Python2/ex03.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex3: Numbers and Math\n\n# Print \"I will now count my chickens:\"\nprint \"I will now count my chickens:\"\n\n# Print the number of hens\nprint \"Hens\", 25 + 30.0 / 6\n# Print the number of roosters\nprint \"Roosters\", 100 - 25 * 3 * 4\n\n# Print \"Now I will count the eggs:\"\nprint \"Now I will count the eggs:\"\n\n# Number of eggs, Notice that '/' operator returns int value in Python2\nprint 3 + 2 + 1 - 5 + 4 % 2 - 1.0 / 4 + 6  # use floating point numbers so it's more accurate \n\n# Print \"Is it true that 3 + 2 < 5 - 7?\"\nprint \"Is it true that 3 + 2 < 5 - 7?\"\n\n# Print whether 3+2 is smaller than 5-7(True or False)\nprint 3 + 2 < 5 - 7\n\n# Calculate 3+2 and print the result\nprint \"What is 3 + 2?\", 3 + 2\n# Calculate 5-7 and print the result\nprint \"What is 5 - 7?\", 5 - 7\n\n# Print \"Oh, that's why it's False.\"\nprint \"Oh, that's why it's False.\"\n\n# Print \"Oh, that's why it's False.\"\nprint \"How about some more.\"\n\n# Print whether 5 is greater than -2(True or False)\nprint \"Is it greater?\", 5 > -2\n# Print whether 5 is greater than or equal to -2?(True or False)\nprint \"Is it greater or equal?\", 5 >= -2\n# Print whether 5 is less than or equal to -2 (True or False)\nprint \"Is it less or equal?\", 5 <= -2\n"
  },
  {
    "path": "Python2/ex04.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex4: Variables And Names\n\n# number of cars\ncars = 100\n# space in a car. Give it a float value, otherwise we can only get int results after division.\nspace_in_a_car = 4.0\n# number of drivers\ndrivers = 30\n# number of passengers\npassengers = 90\n# number of cars that are empty(without driver)\ncars_not_driven = cars - drivers\n# number of cars that are diven\ncars_driven = drivers\n# number of cars \ncarpool_capacity = cars_driven * space_in_a_car\n# average number of passengers in each car\naverage_passengers_per_car = passengers / cars_driven\n\nprint \"There are\", cars, \"cars available.\"\nprint \"There are only\", drivers, \"drivers available.\"\nprint \"There will be\", cars_not_driven, \"empty cars today.\"\nprint \"We can transport\", carpool_capacity, \"people today.\"\nprint \"We have\", passengers, \"to carpool today.\"\nprint \"We need to put about\", average_passengers_per_car, \"in each car.\"\n"
  },
  {
    "path": "Python2/ex05.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex5: More Variables and Printing\n\nname = 'Zed A. Shaw'\nage = 35       # not a lie\nheight = 74   # inches\nweight = 180  # lbs\neyes = \"Blue\"\nteeth = 'White'\nhair = 'Brown'\n\nprint \"Let's talk about %s\" % name\nprint \"He's %d years old.\" % age\nprint \"He's %d inches tall.\" % height\nprint \"He's %d pounds heavy.\" % weight\nprint \"Actually that's not too heavy\"\nprint \"He's got %s eyes and %s hair.\" % (eyes, hair)\nprint \"His teeth are usually %s depending on the coffee.\" % (teeth)\n\n# this line is tricky, try to get it exactly right\nprint 'If I add %d, %d and %d I get %d.' % (age, height, weight, age + height + weight)\n\n# try more format characters\nmy_greeting = \"Hello,\\t\"\nmy_first_name = 'Joseph'\nmy_last_name = 'Pan'\nmy_age = 24\n# Print 'Hello,\\t'my name is Joseph Pan, and I'm 24 years old.\nprint \"%rmy name is %s %s, and I'm %d years old.\" % (my_greeting, my_first_name, my_last_name, my_age)\n\n# Try to write some variables that convert the inches and pounds to centimeters and kilos.\ninches_per_centimeters = 2.54\npounds_per_kilo = 0.45359237\n\nprint \"He's %f centimeters tall.\" % (height * inches_per_centimeters)\nprint \"He's %f kilos heavy.\" % (weight * pounds_per_kilo)\n"
  },
  {
    "path": "Python2/ex06.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex6: String and Text\n\n# Assign the string with 10 replacing the formatting character to variable 'x'\nx = \"There are %d types of people.\" % 10\n\n# Assign the string with \"binary\" to variable 'binary'\nbinary = \"binary\"\n\n# Assign the string with \"don't\" to variable 'do_not'\ndo_not = \"don't\"\n\n# Assign the string with 'binary' and 'do_not' replacing the formatting character to variable 'y'\ny = \"Those who know %s and those who %s.\" % (binary, do_not)  # Two strings inside of a string\n\n# Print \"There are 10 types of people.\"\nprint x\n\n# Print \"Those who know binary and those who don't.\"\nprint y\n\n# Print \"I said 'There are 10 types of people.'\"\nprint \"I said %r.\" % x  # One string inside of a string\n\n# Print \"I also said: 'Those who know binary and those who don't.'.\"\nprint \"I also said: '%s'.\" % y  # One string inside of a string\n\n# Assign boolean False to variable 'hilarious'\nhilarious = False\n\n# Assign the string with an unevaluated formatting character to 'joke_evaluation'\njoke_evaluation = \"Isn't that joke so funny?! %r\" \n\n# Print \"Isn't that joke so funny?! False\"\nprint joke_evaluation % hilarious  # One string inside of a string\n\n# Assign string to 'w'\nw = \"This is the left side of...\"\n\n# Assign string to 'e'\ne = \"a string with a right side.\"\n\n# Print \"This is the left side of...a string with a right side.\"\nprint w + e  # Concatenate two strings with + operator\n"
  },
  {
    "path": "Python2/ex07.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex7: More Printing\n\n# Print \"Mary had a little lamb\" \nprint \"Mary had a little lamb\" \n\n# Print \"Its fleece was white as snow.\nprint \"Its fleece was white as %s.\" % 'snow'  # one string inside of another\n\n# Print \"And everywhere that Mary went.\"\nprint \"And everywhere that Mary went.\"\n\n# Print \"..........\"\nprint \".\" * 10  # what'd that do? - \"*\" operator for strings is used to repeat the same characters for certain times\n\n# Assign string value for each variable\nend1 = \"C\"\nend2 = \"h\"\nend3 = \"e\"\nend4 = \"e\"\nend5 = \"s\"\nend6 = \"e\"\nend7 = \"B\"\nend8 = \"u\"\nend9 = \"r\"\nend10 = \"g\"\nend11 = \"e\"\nend12 = \"r\"\nend10 = \"g\"\nend11 = \"e\"\nend12 = \"r\"\n\n# watch that comma at the end. try removing it to see what happens\nprint end1 + end2 + end3 + end4 + end5 + end6,\nprint end7 + end8 + end9 + end10 + end11 + end12\n"
  },
  {
    "path": "Python2/ex08.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex8: Printing, Printing\n\nformatter = \"%r %r %r %r\"\n\nprint formatter % (1, 2, 3, 4)\nprint formatter % (\"one\", \"two\", \"three\", \"four\")\nprint formatter % (True, False, False, True)\nprint formatter % (formatter, formatter, formatter, formatter)\nprint formatter % (\n    \"I had this thing.\",\n    \"That you could type up right.\",\n    \"But it didn't sing.\",  # This line contains a apostrophe\n    \"So I said goodnight.\"\n    )\n"
  },
  {
    "path": "Python2/ex09.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex9: Printing, Printing, Printing\n\n# Here's some new strange stuff, remember type it exactly.\n\ndays = \"Mon Tue Wed Thu Fri Sat Sun\"\nmonths = \"Jan\\nFeb\\nMar\\nApr\\nMay\\nJun\\nJul\\nAug\"\n\nprint \"Here are the days: \", days\nprint \"Here are the months: \", months\nprint\"I said 'Here are the months: %r'\" % months\n\nprint \"\"\"\nThere's something going on here.\nWith the three double-quotes.\nWe'll be able to type as much as we like.\nEven 4 lines if we want, or 5, or 6.\n\"\"\"\n"
  },
  {
    "path": "Python2/ex10.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex10: What Was That?\n\ntabby_cat = \"\\tI'm tabbed in.\"\npersian_cat = \"I'm split\\non a line.\"\nbackslash_cat = \"I'm \\\\ a \\\\ cat.\"\ntest = \"I will insert a \\newline haha.\"\n\nfat_cat = '''\nI'll do a list:\n\\t* Cat food\n\\t* Fishies\n\\t* Catnip \\n\\t* Grass\n'''\n\nprint tabby_cat\nprint persian_cat\nprint backslash_cat\nprint fat_cat\n\n# Assign string value for each variable\nintro = \"I'll print a week\"\nmon = \"Mon\"\ntue = \"Tue\"\nwed = \"Wed\"\nthu = \"Thu\"\nfri = \"Fri\"\nsat = \"Sat\"\nsun = \"Sun\"\n\nprint \"%s\\n%s\\t%s\\t%s\\t%s\\t%s\\t%s\\t%s\\n\" % (intro, mon, tue, wed, thu, fri, sat, sun)\n\nprint \"%r\" % intro\nprint \"%r\" % \"She said \\\"I'll print a week\\\"\"\n\nprint \"%s\" % intro\nprint \"%s\" % \"She said \\\"I'll print a week\\\"\"\n"
  },
  {
    "path": "Python2/ex11.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex11: Asking Questions\n\n# input(): Read a value from standard input. Equivalent to eval(raw_input(prompt)).\n# raw_input(): Read a string from standard input. The trailing newline is stripped.\n\nprint \"How old are you?\",\nage = raw_input()\nprint \"How tall are you?\",\nheight = raw_input()\nprint \"How much do you weigh?\",\nweight = raw_input()\n\nprint \"So, you're %r old, %r tall and %r heavy.\" % (age, height, weight)\n\nprint \"Enter a integer: \",\nnum = int(raw_input())\nprint \"The number you've input is: %d\" % num\n\nprint \"Enter a name: \",\nname = raw_input()\nprint \"What's %s's age?\" % name,\nage = input()\nprint \"What's %s's height?\" % name,\nheight = input()\nprint \"What's %s's weight?\" % name,\nweight = input()\nprint \"What's the color of %s's eyes?\" % name,\neyes = raw_input() \nprint \"What's the color of %s's teeth?\" % name,\nteeth = raw_input() \nprint \"What's the color of %s's hair?\" % name,\nhair = raw_input() \n\ntype(name)  # the data type of name will be <type 'str'>\ntype(age)   # the data type of age will be <type 'int'>\n\nprint \"Let's talk about %s\" % name\nprint \"He's %d years old.\" % age\nprint \"He's %d inches tall.\" % height\nprint \"He's %d pounds heavy.\" % weight\nprint \"Actually that's not too heavy\"\nprint \"He's got %s eyes and %s hair.\" % (eyes, hair)\nprint \"His teeth are usually %s depending on the coffee.\" % (teeth)\n\nprint 'If I add %d, %d and %d I get %d.' % (age, height, weight, age + height + weight)\n"
  },
  {
    "path": "Python2/ex12.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex12: Prompting People\n\nage = raw_input(\"How old are you?\")\nheight = raw_input(\"How tall are you? \")\nweight = raw_input(\"How much do you weigh? \")\n\nprint \"So, you're %r old, %r tall and %r heavy.\" % (age, height, weight)\n"
  },
  {
    "path": "Python2/ex13-less.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex13: Parameters, Unpacking, Variables\n# Write a script that has fewer arguments\n\nfrom sys import argv\n\nscript, first_name, last_name = argv\n\nprint \"The script is called:\", script\nprint \"Your first name is:\", first_name\nprint \"Your last name is:\", last_name"
  },
  {
    "path": "Python2/ex13-more.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex13: Parameters, Unpacking, Variables\n# Write a script that has more arguments\n\nfrom sys import argv\n\nscript, name, age, height, weight = argv\n\nprint \"The script is called:\", script\nprint \"Your name is:\", name\nprint \"Your age is:\", age\nprint \"Your height is %d inches\" % int(height)\nprint \"Your weight is %d pounds\" % int(weight)"
  },
  {
    "path": "Python2/ex13-raw_input.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex13: Parameters, Unpacking, Variables\n# Combine raw_input with argv to make a script that gets more input from a user.\n\nfrom sys import argv\n\nscript, first_name, last_name = argv\n\nmiddle_name = raw_input(\"What's your middle name?\")\n\nprint \"Your full name is %s %s %s.\" % (first_name, middle_name, last_name)"
  },
  {
    "path": "Python2/ex13.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex13: Parameters, Unpacking, Variables\n\nfrom sys import argv\n\nscript, first, second, third = argv\n\nprint \"The script is called:\", script\nprint \"Your first variable is:\", first\nprint \"Your second variable is:\", second\nprint \"Your third variable is:\", third"
  },
  {
    "path": "Python2/ex14.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex14: Prompting and Passing\n\nfrom sys import argv\n\n# Add another argument and use it in your script\nscript, user_name, city = argv\n# prompt = '> '\n# Change the prompt variable to something else\nprompt = 'Please type the answer: '\n\nprint \"Hi %s from %s, I'm the %s script.\" % (user_name, city, script)\nprint \"I'd like to ask you a few questions.\"\nprint \"Do you like me %s?\" % user_name\nlikes = raw_input(prompt)\n\nprint \"What's the whether like today in %s?\" % city\nweather = raw_input(prompt)\n\nprint \"What kind of computer do you have?\"\ncomputer = raw_input(prompt)\n\nprint \"\"\"\nAlright, so you said %r about liking me.\nThe weather in your city is %s. \nBut I can't feel it because I'm a robot.\nAnd you have a %r computer.  Nice.\n\"\"\" % (likes, weather, computer)\n"
  },
  {
    "path": "Python2/ex15.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex15: Reading Files\n\n# import argv variables from sys submodule\nfrom sys import argv\n\n# get the argv variables\nscript, filename = argv\n\n# open a file\ntxt = open(filename)\n\n# print file name\n# print all the contents of the file\nprint txt.read()\n\n# close the file\ntxt.close()\n\n# prompt to type the file name again\nprint \"Type the filename again:\"\n# input the new file name\nfile_again = raw_input(\"> \")\n\n# open the new selected file\ntxt_again = open(file_again)\n\n# print the contents of the new selected file\nprint txt_again.read()\n\n# close the file\ntxt_again.close()\n"
  },
  {
    "path": "Python2/ex16.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex16: Reading and Writing Files\n\nfrom sys import argv\n\nscript, filename = argv\n\nfrom sys import argv\n\nscript, filename = argv\n\nprint \"We're going to erase %r.\" % filename\nprint \"If you don't want that, hit CTRL-C (^C).\"\nprint \"If you do want that, hit RETURN.\"\n\nraw_input(\"?\")\n\nprint \"Opening the file...\"\n# Open this file in 'write' mode\ntarget = open(filename, 'w')\n\n# Not neccessary if opening the file with 'w' mode\n# target.truncate()\nprint \"Truncating the file.  Goodbye!\"\ntarget.truncate()\n\nprint \"Now I'm going to ask you for three lines.\"\n\nline1 = raw_input(\"line 1: \")\nline2 = raw_input(\"line 2: \")\nline3 = raw_input(\"line 3: \")\n\nprint \"I'm going to write these to the file.\"\n\ntarget.write(\"%s\\n%s\\n%s\\n\" % (line1, line2, line3))\n\nprint \"And finally, we close it.\"\ntarget.close()\n"
  },
  {
    "path": "Python2/ex16_read.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# A script similar to ex16 that uses read and argv to read the file\n\nfrom sys import argv\n\nscript, filename = argv\n\nprint \"The contents of the file %s:\" % filename\ntarget = open(filename)\ncontents = target.read()\nprint contents\ntarget.close()\n"
  },
  {
    "path": "Python2/ex17.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex17: More Files\n\nfrom sys import argv\nfrom os.path import exists\n\nscript, from_file, to_file = argv\n\nopen(to_file, 'w').write(open(from_file).read())\n"
  },
  {
    "path": "Python2/ex18.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex18: Names, Variables, Code, Functions\n\n# this one is like your scripts with argv\ndef print_two(*args):\n    arg1, arg2 = args\n    print \"arg1: %r, arg2: %r\" % (arg1, arg2)\n\n# ok, that *args is actually pointless, we can just do this\ndef print_two_again(arg1, arg2):\n    print \"arg1: %r, arg2: %r\" % (arg1, arg2)\n\n# this just takes one argument\ndef print_one(arg1):\n    print \"arg1: %r\" % arg1\n\n# this one takes no arguments\ndef print_none():\n    print \"I got nothin'.\"\n\nprint_two(\"Zed\",\"Shaw\")\nprint_two_again(\"Zed\",\"Shaw\")\nprint_one(\"First!\")\nprint_none()\n"
  },
  {
    "path": "Python2/ex19.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex19: Functions and Variables\n\n# Define a function named \"cheese_and_crackers\"\ndef cheese_and_crackers(cheese_count, boxes_of_crackers):\n    print \"You have %d cheeses!\" % cheese_count\n    print \"You have %d boxes of crackers!\" % boxes_of_crackers\n    print \"Man that's enough for a party!\"\n    print \"Get a blanket.\\n\"\n\n\n# Print \"We can just give the function numbers directly:\"\nprint \"We can just give the function numbers directly:\"\n# Call the function, with 2 numbers as the actual parameters\ncheese_and_crackers(20, 30)\n\n# Print \"OR, we can use variables from our script:\"\nprint \"OR, we can use variables from our script:\"\n# assign 10 to a variable named amount_of_cheese\namount_of_cheese = 10\n# assign 50 to a variable named amount_of_crackers\namount_of_crackers = 50\n\n# Call the function, with 2 variables as the actual parameters\ncheese_and_crackers(amount_of_cheese, amount_of_crackers)\n\n# Print \"We can even do math inside too:\"\nprint \"We can even do math inside too:\"\n# Call the function, with two math expression as the actual\n# parameters. Python will first calculate the expressions and then\n# use the results as the actual parameters \ncheese_and_crackers(10 + 20, 5 + 6)\n\n# Print \"And we can combine the two, variables and math:\"\nprint \"And we can combine the two, variables and math:\"\n# Call the function, with two expression that consists of variables\n# and math as the actual parameters\ncheese_and_crackers(amount_of_cheese + 100, amount_of_cheese + 1000)\n\n\ndef print_args(*argv):\n    size = len(argv)\n    print size\n    print \"Hello! Welcome to use %r!\" % argv[0]\n    if size > 1:\n        for i in range(1, size):\n            print \"The param %d is %r\" % (i, argv[i])\n        return 0\n    return -1\n\n\n# 1. use numbers as actual parameters\nprint_args(10, 20, 30)\n\n# 2. use string and numbers as actual parameters\nprint_args(\"print_args\", 10, 20)\n\n# 3. use strings as actual parameters\nprint_args(\"print_args\", \"Joseph\", \"Pan\")\n\n# 4. use variables as actual parameters\nfirst_name = \"Joseph\"\nlast_name = \"Pan\"\nprint_args(\"print_args\", first_name, last_name)\n\n# 5. contain math expressions\nprint_args(\"print_args\", 5*4, 2.0/5)\n\n# 6. more complicated calculations\nprint_args(\"print_args\", '.'*10, '>'*3)\n\n# 7. more parameters\nprint_args(\"print_args\", 10, 20, 30, 40, 50)\n\n# 8. tuples as parameters\nnums1 = (10, 20, 30)\nnums2 = (40, 50, 60)\nprint_args(\"print_args\", nums1, nums2)\n\n# 9. more complicated types\nnums3 = [70, 80, 90]\nset1 = {\"apple\", \"banana\", \"orange\"}\ndict1 = {'id': '0001', 'name': first_name+\" \"+last_name}\nstr1 = \"Wow, so complicated!\"\nprint_args(\"print args\", nums1, nums2, nums3, set1, dict1, str1)\n\n# 10. function as parameter and return values\nif print_args(cheese_and_crackers, print_args) != -1:\n    print \"You just send more than one parameter. Great!\"\n"
  },
  {
    "path": "Python2/ex20.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex20: Functions and Files\n\n# Import argv variables from the sys module\nfrom sys import argv\n\n# Assign the first and the second arguments to the two variables\nscript, input_file = argv\n\n# Define a function called print_call to print the whole contents of a\n# file, with one file object as formal parameter\ndef print_all(f):\n    # print the file contents\n    print f.read()\n\n\n# Define a function called rewind to make the file reader go back to\n# the first byte of the file, with one file object as formal parameter\ndef rewind(f):\n    # make the file reader go back to the first byte of the file\n    f.seek(0)\n\n\n# Define a function called print_a_line to print a line of the file,\n# with a integer counter and a file object as formal parameters\ndef print_a_line(line_count, f):\n    # Test whether two variables are carrying the same value\n    print \"line_count equal to current_line?:\", (line_count == current_line)\n    # print the number and the contents of a line\n    print line_count, f.readline()\n\n\n# Open a file\ncurrent_file = open(input_file)\n\n# Print \"First let's print the whole file:\"\nprint \"First let's print the whole file:\\n\"\n\n# call the print_all function to print the whole file\nprint_all(current_file)\n\n# Print \"Now let's rewind, kind of like a tape.\"\nprint \"Now let's rewind, kind of like a tape.\"\n\n# Call the rewind function to go back to the beginning of the file\nrewind(current_file)\n\n# Now print three lines from the top of the file\n\n# Print \"Let's print three lines:\"\nprint \"Let's print three lines:\"\n\n# Set current line to 1\ncurrent_line = 1\nprint \"current_line = %d\" % current_line\n# Print current line by calling print_a_line function\nprint_a_line(current_line, current_file)\n\n# Set current line to 2 by adding 1\ncurrent_line += 1\nprint \"current_line is equal to:%d\" % current_line\n# Print current line by calling print_a_line function\nprint_a_line(current_line, current_file)\n\n# Set current line to 3 by adding 1\ncurrent_line += 1\nprint \"current_line is equal to:%d\" % current_line\n# Print current line by calling print_a_line function\nprint_a_line(current_line, current_file)\n"
  },
  {
    "path": "Python2/ex21.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex21: Functions Can Return Something\n\n\ndef add(a, b):\n    print \"ADDING %d + %d\" % (a, b)\n    return a + b\n\n\ndef subtract(a, b):\n    print \"SUBTRACTING %d - %d\" % (a, b)\n    return a - b\n\n\ndef multiply(a, b):\n    print \"MULTIPLYING %d * %d\" % (a, b)\n    return a * b\n\n\ndef divide(a, b):\n    print \"DIVIDING %d / %d\" % (a, b)\n    return a / b\n\n\n# my function to test return\ndef isequal(a, b):\n    print \"Is %r equal to %r? - \" % (a, b) ,\n    return (a == b)\n\n\nprint \"Let's do some math with just functions!\"\n\nage = add(30, 5)\nheight = subtract(78, 4)\nweight = multiply(92, 2)\niq = divide(100, 2)\n\nprint \"Age: %d, Height: %d, Weight: %d, IQ: %d\" % (age, height, weight, iq)\n\n\n# A puzzle for the extra credit, type it in anyway.\nprint \"Here is a puzzle.\"\n\n# switch the order of multiply and divide\nwhat = add(age, subtract(height, divide(weight, multiply(iq, 2))))\n\nprint \"That becomes: \", what, \"Can you do it by hand?\"\n\n# test the return value of isequal()\nnum1 = 40\nnum2 = 50\nnum3 = 50\n\nprint isequal(num1, num2)\nprint isequal(num2, num3)\n\n\n# A new puzzle.\nprint \"Here is a new puzzle.\"\n\n# write a simple formula and use the function again\nuplen = 50\ndownlen = 100\nheight = 80\nwhat_again = divide(multiply(height, add(uplen, downlen)), 2)\n\nprint \"That become: \", what_again, \"Bazinga!\"\n"
  },
  {
    "path": "Python2/ex24.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex24: More Practice\n\nprint \"Let's practice everything.\"\nprint \"You\\'d need to know \\'bout escapes with \\\\ that do \\n newlines and \\t tabs.\"\n\npoem = \"\"\"\n\\t The lovely world\nwith logic so firmly planted\ncannot discern \\n the needs of love\nnor comprehend passion from intuition\nand requires an explanation\n\\n\\t\\twhere there is none.\n\"\"\"\n\nprint \"--------------------\"\nprint poem\nprint \"--------------------\"\n\n\nfive = 10 - 2 + 3 - 6\nprint \"This should be five: %s\" % five\n\n\ndef secret_formala(started):\n    jelly_beans = started * 500\n    jars = jelly_beans / 1000\n    crates = jars / 100\n    return jelly_beans, jars, crates\n\n\nstart_point = 1000\nbeans, jars, crates = secret_formala(start_point)\n\nprint \"With a starting point of: %d\" % start_point\n# use the tuple as the parameters for the formatter\nprint \"We'd have %d beans, %d jars, and %d crates.\" % (beans, jars, crates)\n\nstart_point = start_point / 10\n\n# call the function and use its return values as the parameters for the formatter\nprint \"We can also do that this way:\"\nprint \"We'd have %d beans, %d jars, and %d crates.\" % secret_formala(start_point)\n"
  },
  {
    "path": "Python2/ex25.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex: even more practice\n\n\ndef break_words(stuff):\n    \"\"\" This function will break up words for us. \"\"\"\n    words = stuff.split(' ')\n    return words\n\n\ndef sort_words(words):\n    \"\"\" Sorts the words. \"\"\"\n    return sorted(words)\n\n\ndef print_first_word(words):\n    \"\"\" Prints the first word after popping it off. \"\"\"\n    word = words.pop(0)\n    print word\n\n\ndef print_last_word(words):\n    \"\"\" Prints the last word after popping it off. \"\"\"\n    word = words.pop(-1)\n    print word\n\n\ndef sort_sentence(sentence):\n    \"\"\" Takes in a full sentence and returns the sorted words. \"\"\"\n    words = break_words(sentence)\n    return sort_words(words)\n\n\ndef print_first_and_last(senence):\n    \"\"\" Prints the first and last words of the sentences. \"\"\"\n    words = break_words(senence)\n    print_first_word(words)\n    print_last_word(words)\n\n\ndef print_first_and_last_sorted(sentence):\n    \"\"\" Sorts the words then prints the first and last one. \"\"\"\n    words = sort_sentence(sentence)\n    print_first_word(words)\n    print_last_word(words)\n"
  },
  {
    "path": "Python2/ex26.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\ndef break_words(stuff):\n    \"\"\"This function will break up words for us.\"\"\"\n    words = stuff.split(' ')\n    return words\n\ndef sort_words(words):\n    \"\"\"Sorts the words.\"\"\"\n    return sorted(words)\n\n# bug: def print_first_word(words)\ndef print_first_word(words):\n    \"\"\"Prints the first word after popping it off.\"\"\"\n    # bug: word = words.poop(0)\n    word = words.pop(0)\n    print word\n\ndef print_last_word(words):\n    \"\"\"Prints the last word after popping it off.\"\"\"\n    # bug: word = words.pop(-1\n    word = words.pop(-1)\n    print word\n\ndef sort_sentence(sentence):\n    \"\"\"Takes in a full sentence and returns the sorted words.\"\"\"\n    words = break_words(sentence)\n    return sort_words(words)\n\ndef print_first_and_last(sentence):\n    \"\"\"Prints the first and last words of the sentence.\"\"\"\n    words = break_words(sentence)\n    print_first_word(words)\n    print_last_word(words)\n\ndef print_first_and_last_sorted(sentence):\n    \"\"\"Sorts the words then prints the first and last one.\"\"\"\n    words = sort_sentence(sentence)\n    print_first_word(words)\n    print_last_word(words)\n\n\nprint \"Let's practice everything.\"\nprint 'You\\'d need to know \\'bout escapes with \\\\ that do \\n newlines and \\t tabs.'\n\npoem = \"\"\"\n\\tThe lovely world\nwith logic so firmly planted\ncannot discern \\n the needs of love\nnor comprehend passion from intuition\nand requires an explantion\n\\n\\t\\twhere there is none.\n\"\"\"\n\n\nprint \"--------------\"\nprint poem\nprint \"--------------\"\n\n# warning: it's not five\nfive = 10 - 2 + 3 - 5\nprint \"This should be five: %s\" % five\n\n\ndef secret_formula(started):\n    jelly_beans = started * 500\n    # bug: jars = jelly_beans \\ 1000\n    jars = jelly_beans / 1000\n    crates = jars / 100\n    return jelly_beans, jars, crates\n\n\nstart_point = 10000\n# bug: beans, jars, crates == secret_formula(start-point)\nbeans, jars, crates = secret_formula(start_point)\n\nprint \"With a starting point of: %d\" % start_point\nprint \"We'd have %d jeans, %d jars, and %d crates.\" % (beans, jars, crates)\n\nstart_point = start_point / 10\n\nprint \"We can also do that this way:\"\n# bug: print \"We'd have %d beans, %d jars, and %d crabapples.\" %\n# secret_formula(start_pont\nprint \"We'd have %d beans, %d jars, and %d crabapples.\" % secret_formula(start_point)\n\n\n# bug: sentence = \"All god\\tthings come to those who weight.\"\nsentence = \"All good things come to those who weight.\"\n\n# bug: words = ex25.break_words(sentence)\nwords = break_words(sentence)\n# bug: sorted_words = ex25.sort_words(words)\nsorted_words = sort_words(words)\n\nprint_first_word(words)\nprint_last_word(words)\n# bug: .print_first_word(sorted_words)\nprint_first_word(sorted_words)\nprint_last_word(sorted_words)\n# bug: sorted_words = ex25.sort_sentence(sentence)\nsorted_words = sort_sentence(sentence)\n# bug: prin sorted_words\nprint sorted_words\n# bug: print_irst_and_last(sentence)\nprint_first_and_last(sentence)\n\n# bug:   print_first_a_last_sorted(senence)\nprint_first_and_last_sorted(sentence)\n"
  },
  {
    "path": "Python2/ex29.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex29: What If\n\npeople = 20\ncats = 30\ndogs = 15\n\n\nif people < cats:\n    print \"Too many cats! The world is doomed!\"\n\nif people > cats:\n    print \"Not many cats! The world is saved!\"\n\nif people < dogs:\n    print \"The world is drooled on!\"\n\nif people > dogs:\n    print \"The world is dry!\"\n\ndogs += 5\n\nif people >= dogs:\n    print \"People are greater than or equal to dogs.\"\n\nif people <= dogs:\n    print \"People are less than or equal to dogs.\"\n\nif people == dogs:\n    print \"People are dogs.\"\n\nif (dogs < cats) and (people < cats):\n    print \"Cats are more than people and dogs. People are scared by cats!\"    \n\nif (dogs < cats) and not (people < cats):\n    print \"Cats are more than dogs. Mice are living a hard life!\"\n    \nif (dogs == cats) or (cats < 10):\n    print \"Cats are fighting against dogs! Mice are happy!\"\n\nif cat != 0: \n    print \"Cats are still exist. Mice cannot be too crazy.\"\n"
  },
  {
    "path": "Python2/ex30.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex30: Else and If\n\n# assign 30 to variable people\npeople = 30\n# assign 40 to variable cars\ncars = 40\n# assign 15 to variable buses\nbuses = 15\n\n# if cars are more than people\nif cars > people:\n    # print \"We should take the cars.\" \n    print \"We should take the cars.\"\n# if cars are less than people   \nelif cars < people:\n    # print \"We should not take the cars\"\n    print \"We should not take the cars\"\n# if cars are equal to people       \nelse:\n    print \"We can't decide.\"\n\n# if buses are more than cars    \nif buses > cars:\n    # print \"That's too many buses.\"\n    print \"That's too many buses.\"\n# if buses are less than cars    \nelif buses < cars:\n    # print \"Maybe we could take the buses.\"\n    print \"Maybe we could take the buses.\"\n# if buses are equal to cars    \nelse:\n    # print \"We still can't decide.\"\n    print \"We still can't decide.\"\n\n# if people are more than buses\nif people > buses:\n    # print \"Alright, let's just take the buses.\"\n    print \"Alright, let's just take the buses.\"\n# if people are less than buses\nelse:\n    # print \"Fine, let's stay home then.\"\n    print \"Fine, let's stay home then.\"\n\n# if people are more than cars but less than buses\nif people > cars and people < buses:\n    # print \"There are many Busses but few cars.\"\n    print \"There are many Busses but few cars.\"\n# if people are less than cars but more than buses\nelif people < cars and people > buses:\n    # print \"There are many cars but few busses.\"\n    print \"There are many cars but few busses.\"\n# if people are more than cars and buses\nelif people > cars and people > buses:\n    # print \"There are few busses and cars.\"\n    print \"There are few busses and cars.\"\n# if people are less than cars and buses    \nelse:\n    # print \"There are many busses and cars.\"\n    print \"There are many busses and cars.\"\n"
  },
  {
    "path": "Python2/ex31.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex31: Making Decisions\n\nprint \"You enter a dark room with two doors. Do you go through...?\"\nprint \"door #1\"\nprint \"door #2\"\nprint \"door #3\"\n\ndoor = raw_input(\"> \")\n\nif door == \"1\":\n    print \"There's a giant bear here eating a cheese cake. What do you do?\"\n    print \"1. Take the cake.\"\n    print \"2. Scream at the bear.\"\n\n    bear = raw_input(\"> \")\n\n    if bear == \"1\":\n        print \"The bear eats your face off. Good job!\"\n    elif bear == \"2\":\n        print \"The bear eats your legs off. Good job!\"\n    else:\n        print \"Well, doing %s is probably better. Bear runs away.\" % bear\n\nelif door == \"2\":\n    print \"You stare into the endless abyss at Cthulhu's retina.\"\n    print \"1. Blueberries.\"\n    print \"2. Yellow jacket clothespins.\"\n    print \"3. Understanding revolvers yelling melodies.\"\n\n    insanity = raw_input(\"> \")\n\n    if insanity == \"1\" or insanity == \"2\":\n        print \"Your body survives powered by a mind of jello. Good job!\"\n    else:\n        print \"The insanity rots you \"\n\nelif door == \"3\":\n    print \"You are asked to select one pill from two and take it. One is red, and the other is blue.\"\n    print \"1. take the red one.\"\n    print \"2. take the blue one.\"\n\n    pill = raw_input(\"> \")\n\n    if pill == \"1\":\n        print \"You wake up and found this is just a ridiculous dream. Good job!\"\n    elif pill == \"2\":\n        print \"It's poisonous and you died.\"\n    else:\n        print \"The man got mad and killed you.\"\n\n\nelse:\n    print \"You wake up and found this is just a ridiculous dream.\"\n    print \"However you feel a great pity haven't entered any room and found out what it will happens!\"\n"
  },
  {
    "path": "Python2/ex32.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex32: Loops and Lists\n\nthe_count = [1, 2, 3, 4, 5]\nfruits = ['apples', 'oranges', 'pears', 'apricots']\nchange = [1, 'pennies', 2, 'dimes', 3, 'quarters']\n\n# this first kind of for-loop goes through a list\nfor number in the_count:\n    print \"This is count %d\" % number\n\n\n# same as above\nfor fruit in fruits:\n    print \"A fruit of type: %s\" % fruit\n\n\n# also we can go through mixed lists too\n# notice we have to use %r since we don't know what's in it\nfor i in change:\n    print \"I got %r\" % i\n\n# we can also build lists, first start with an empty one\nelements = []\n\n# then use the range function to generate a list\nelements = range(0, 6)\n    \n# now we can print them out too\nfor i in elements:\n    print \"Element was: %d\" % i\n"
  },
  {
    "path": "Python2/ex33.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex33: While Loops\n\ndef createNumbers(max, step):\n    i = 0\n    numbers = []\n    for i in range(0, max, step):\n        print \"At the top i is %d\" % i\n        numbers.append(i)\n\n        print \"Numbers now: \", numbers\n        print \"At the bottom i is %d\" % i\n    return numbers\n\nnumbers = createNumbers(10, 2)\n\nprint \"The numbers: \"\n\nfor num in numbers:\n    print num\n"
  },
  {
    "path": "Python2/ex34.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex34: Accessing Elements of Lists\n\nanimals = ['bear', 'python', 'peacock', 'kangaroo', 'whale', 'platypus']\n\ndef printAnimal(index):\n    if index == 1:\n        num2en = \"1st\"\n    elif index == 2:\n        num2en = \"2nd\"\n    elif index == 3:\n        num2en = \"3rd\"\n    else:\n        num2en = str(index)+\"th\"\n    print \"The %s animal is at %d and is a %s\" % (num2en, index-1, animals[index-1])\n    print \"The animal at %d is the %s animal and is a %s\" % (index-1, num2en, animals[index-1])\n\nfor i in range(1, 7):\n    printAnimal(i)\n"
  },
  {
    "path": "Python2/ex35.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex35: Branches and Functions\n\nfrom sys import exit\n\ndef gold_room():\n    ''' A room with full of god. '''\n    print \"This room is full of gold.  How much do you take?\"\n\n    next = raw_input(\"> \")\n\n    try:\n         how_much = int(next)\n    except ValueError:\n        dead(\"Man, learn to type a number.\")\n\n    if how_much < 50:\n        print \"Nice, you're not greedy, you win!\"\n        exit(0)\n    else:\n        dead(\"You greedy bastard!\")\n\n\ndef bear_room():\n    ''' A room with a bear '''\n    print \"There is a bear here.\"\n    print \"The bear has a bunch of honey.\"\n    print \"The fat bear is in front of another door.\"\n    print \"How are you going to move the bear?\"\n    bear_moved = False\n\n    while True:\n        next = raw_input(\"> \")\n\n        if next == \"take honey\":\n            dead(\"The bear looks at you then slaps your face off.\")\n        elif next == \"taunt bear\" and not bear_moved:\n            print \"The bear has moved from the door. You can go through it now.\"\n            bear_moved = True\n        elif next == \"taunt bear\" and bear_moved:\n            dead(\"The bear gets pissed off and chews your leg off.\")\n        elif next == \"open door\" and bear_moved:\n            gold_room()\n        else:\n            print \"I got no idea what that means.\"\n\n\ndef cthulhu_room():\n    ''' A room with evil Cthulhu '''\n    print \"Here you see the great evil Cthulhu.\"\n    print \"He, it, whatever stares at you and you go insane.\"\n    print \"Do you flee for your life or eat your head?\"\n\n    next = raw_input(\"> \")\n\n    if \"flee\" in next:\n        start()\n    elif \"head\" in next:\n        dead(\"Well that was tasty!\")\n    else:\n        cthulhu_room()\n\n\ndef dead(why):\n    ''' Call this when the hero dead '''\n    print why, \"Good job!\"\n    exit(0)\n\ndef start():\n    ''' Begining of the story '''\n    print \"You are in a dark room.\"\n    print \"There is a door to your right and left.\"\n    print \"Which one do you take?\"\n\n    next = raw_input(\"> \")\n\n    if next == \"left\":\n        bear_room()\n    elif next == \"right\":\n        cthulhu_room()\n    else:\n        dead(\"You stumble around the room until you starve.\")\n\n\nstart()\n"
  },
  {
    "path": "Python2/ex37.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex37: Symbol Review\n\n# and, or, not, if, elif, else\n\nprint \"#1##############################\"\n\nif True and False:\n    print \"#1 can't be printed\"\n\nif False and False:\n    print \"#2 can't be printed\"\n\nif True and True:\n    print \"#3 can be printed!\"\n\nif False or True:\n    print \"#4 can be printed!\"\n\nif True or False:\n    print \"#5 can be printed!\"\n\nif True or No_Matter_What:\n    print \"#6 can be printed!\"\n\nif not(False and No_Matter_What):\n    print \"#7 can be printed!\"\n\nrainy = True\nsunny = False\nif rainy:\n    print \"It's rainny today!\"\nelif sunny:\n    print \"It's sunny today!\"\nelse:\n    print \"It's neither rainny nor sunny today!\"\n\n\n# del, try, except, as\n\nprint \"#2##############################\"\n\nx = 10\nprint x\n\ndel x\ntry:\n    print x\nexcept NameError as er:\n    print er\n\n    \n# from, import\n\nprint \"#3##############################\"\n\nfrom sys import argv\nscript = argv\nprint \"The script name is %s \" % script\n\n# for, in\nfor i in range(0, 10):\n    print i,\n\n# assert\ntry:\n    assert True, \"\\nA True!\"\n    assert False, \"\\nA false!\"\nexcept AssertionError as er:\n    print er\n\n# global, def\nprint \"#4##############################\"\nx = 5\n\ndef addone():\n    # annouce that x is the global x\n    global x\n    x += 1\n\naddone()\nprint \"x is %d\", x\n\n# finally\n\nprint \"#4##############################\"\n\nimport time\ntry:\n    f = open('sample.txt')\n    while True: # our usual file-reading idiom\n        line = f.readline()\n        if len(line) == 0:\n            break\n        print line \nexcept KeyboardInterrupt:\n    print '!! You cancelled the reading from the file.'\nfinally:\n    f.close()\n    print '(Cleaning up: Closed the file)'\n    \n# with\n\nprint \"#5##############################\"\n\nwith open(\"sample.txt\") as f:\n    print f.read()\n\n# pass, class\n\nprint \"#6##############################\"\n\nclass NoneClass:\n    ''' Define an empty class. '''\n    pass\n\nempty = NoneClass()\nprint(empty)\n\nclass Droid:\n    ''' Define a robot with a name. '''\n    def __init__(self, name):\n        self.name = name\n        print \"Robot %s initialized.\" % self.name\n    def __del__(self):\n        print \"Robot %s destroyed.\" % self.name\n    def sayHi(self):\n        print \"Hi, I'm %s.\" % self.name\n\nr2d2 = Droid('R2D2')\nr2d2.sayHi()\ndel r2d2\n\n# exec\n\nprint \"#7##############################\"\n\nprint \"Here I will use exec function to calculate 5 + 2\"\nexec(\"print '5 + 2 = ' , 5 + 2\")\n\n# while, break\n\nprint \"#8##############################\"\n\nwhile True:\n    try:\n        num = int(raw_input(\"Let's guess an integer:\"))\n        if num > 10:\n            print \"too big!\"\n        elif num < 10:\n            print \"too small!\"\n        else:\n            print(\"Congrats! You will!\")\n            break\n    except ValueError:\n        print \"Please insert a value!\"\n\n# raise\n\nprint \"#9##############################\"\n\nclass ShortInputException(Exception):\n    ''' A user-defined exception class. '''\n    def __init__(self, length, atleast):\n        Exception.__init__(self)\n        self.length = length\n        self.atleast = atleast\ntry:\n    text = raw_input('Enter something long enough --> ')\n    if len(text) < 3:\n        raise ShortInputException(len(text), 3)\n    # Other work can continue as usal here\nexcept EOFError:\n    print 'Why did you do an EOF on me?'\nexcept ShortInputException as ex:\n    print 'ShortInputException: The input was {0} long, expected at least {1}'\\\n          .format(ex.length, ex.atleast)    \nelse:\n    print('No exception was raised.')\n\n# yield\n\nprint \"#10##############################\"\n\nprint \"Now we counter from 1 to 99: \"\n\ndef make_counter(max):\n    x = 1\n    while x < max:\n        yield x\n        x = x + 1\n\nfor i in make_counter(100):\n    print i,\n\nprint \"\\n\\nNow we calculate fibonacci series: \"            \n    \ndef fib(max):\n    ''' A fibonacci secries generator.\n\n    Calculates fibonacci numbers from 0 to max.\n     '''\n    a, b = 0, 1\n    while a < max:\n        yield a\n        a, b = b, a+b\n\nfor num in fib(100):\n    print num,\n\n# lambda\n\nprint \"\\n#11##############################\"\n\ndef makeDouble():\n    ''' double given value '''\n    return lambda x:x * 2\n\nadder = makeDouble()\nnum_list = [5, 10, 15, 'hello']\nprint '\\nNow we multiples each elements in num_list with 2:'\nfor num in num_list:\n    print adder(num)\n"
  },
  {
    "path": "Python2/ex38.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex38: Doing Things To Lists\n\nten_things = \"Apples Oranges Crows Telephone Light Sugar\"\n\nprint \"Wait there's not 10 things in that list, let's fix that.\"\n\nstuff = ten_things.split(' ')\nmore_stuff = [\"Day\", \"Night\", \"Song\", \"Frisbee\", \"Corn\", \"Banana\", \"Girl\", \"Boy\"]\n\nwhile len(stuff) != 10:\n    next_one = more_stuff.pop()\n    print \"Adding: \", next_one\n    stuff.append(next_one)\n    print \"There's %d items now.\" % len(stuff)\n\nprint \"There we go: \", stuff\n\nprint \"Let's do some things with stuff.\"\n\nprint stuff[1]\nprint stuff[-1]  # whoa! fancy\nprint stuff.pop()\nprint ' '.join(stuff)  # what? cool!\nprint '#'.join(stuff[3:5])  # super stellar!\n"
  },
  {
    "path": "Python2/ex39.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex39: Dictionaries, Oh Lovely Dictionaries\n\n# create a mapping of state to abbreviation\nstates = {\n    'Oregon': 'OR',\n    'Florida': 'FL',\n    'California': 'CA',\n    'New York': 'NY',\n    'Michigan': 'MI'\n}\n\n# create a basic set of states and some cities in them\ncities = {\n    'CA': 'San Fransisco',\n    'MI': 'Detroit',\n    'FL': 'Jacksonville'\n    }\n\n# add some more cities\ncities['NY'] = 'New York'\ncities['OR'] = 'Portland'\n\n# print out some cities\nprint '-' * 10\nprint \"NY State has: \", cities['NY']\nprint 'OR State has: ', cities['OR']\n\n# do it by using the state then cities dict\nprint '-' * 10\nprint \"Michigan has: \", cities[states['Michigan']]\nprint \"Florida has:\", cities[states['Florida']]\n\n# print every state abbreviation\nprint '-' * 10\nfor state, abbrev in states.items():\n    print \"%s is abbreviated %s\" % (state, abbrev)\n\n# print every city in state\nprint '-' * 10\nfor abbrev, city in cities.items():\n    print \"%s has the city %s\" % (abbrev, city)\n\n# now do both at the same time\nprint '-' * 10\nfor state, abbrev in states.items():\n    print \"%s state is abbreviated %s and has city %s\" % (\n        states, abbrev, cities[abbrev])\n\nprint '-' * 10\n# safely get a abbreviation by state that might not be there\nstate = states.get('Texas', None)\n\nif not state:\n    print \"Sorry, no Texas.\"\n\n# get a city with a default value\ncity = cities.get('TX', 'Does Not Exist')\nprint \"The city for the state 'TX' is %s\" % city\n\n# create a mapping of province to abbreviation\ncn_province = {\n    '广东': '粤',\n    '湖南': '湘',\n    '四川': '川',\n    '云南': '滇',\n    }\n\n# create a basic set of provinces and some cities in them\ncn_cities = {\n    '粤': '广州',\n    '湘': '长沙',\n    '川': '成都',\n    }\n\n# add some more data\ncn_province['台湾'] = '台'\n\ncn_cities['滇'] = '昆明'\ncn_cities['台'] = '高雄'\n\nprint '-' * 10\nfor prov, abbr in cn_province.items():\n    print \"%s省的缩写是%s\" % (prov, abbr)\n\nprint '-' * 10\ncn_abbrevs = {values: keys for keys, values in cn_province.items()}\nfor abbrev, prov in cn_abbrevs.items():\n    print \"%s是%s省的缩写\" % (abbrev, prov)\n\nprint '-' * 10\nfor abbrev, city in cn_cities.items():\n    print \"%s市位于我国的%s省\" % (city, cn_abbrevs[abbrev])\n\n"
  },
  {
    "path": "Python2/ex40.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex40: Modules, Classes, and Objects\n\n# a first class example\n\nclass Song(object):\n\n    def __init__(self, disk):\n        self.index = 0\n        self.disk = disk\n        self.jump()\n\n    def next(self):\n        ''' next song. '''\n        self.index = (self.index + 1) % len(self.disk)\n        self.jump()\n\n    def prev(self):\n        ''' prev song. '''\n        self.index = (self.index - 1) % len(self.disk)\n        self.jump()\n            \n    def jump(self):\n        ''' jump to the song. '''\n        self.lyrics = self.disk[self.index]\n\n    def sing_me_a_song(self):\n        for line in self.lyrics:\n            print line\n\n# construct a disk      \nsong1 =  [\"Happy birthday to you\",\n\"I don't want to get sued\",\n\"So I'll stop right there\"]           \n\nsong2 = [\"They rally around the family\",\n\"With pockets full of shells\"\n]\n\nsong3 = [\"Never mind I find\",\n\"Some one like you\"\n]\n\ndisk = [song1, song2, song3]\n\nmycd = Song(disk)\nmycd.sing_me_a_song()\n\nmycd.next()\nmycd.sing_me_a_song()\n\nmycd.next()\nmycd.sing_me_a_song()\n\nmycd.next()\nmycd.sing_me_a_song()\n\nmycd.prev()\nmycd.sing_me_a_song()\n\nmycd.prev()\nmycd.sing_me_a_song()\n\nmycd.prev()\nmycd.sing_me_a_song()\n\nmycd.prev()\nmycd.sing_me_a_song()\n"
  },
  {
    "path": "Python2/ex41.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex41: Learning To Speak Object Oriented\n\nimport random\nfrom urllib import urlopen\nimport sys\n\nWORD_URL = \"http://learncodethehardway.org/words.txt\"\nWORDS = []\n\nPHRASES = {\n    \"class %%%(%%%):\":\n      \"Make a class named %%% that is-a %%%.\",\n    \"class %%%(object):\\n\\tdef __init__(self, ***)\" :\n      \"class %%% has-a __init__ that takes self and *** parameters.\",\n    \"class %%%(object):\\n\\tdef ***(self, @@@)\":\n      \"class %%% has-a function named *** that takes self and @@@ parameters.\",\n    \"*** = %%%()\":\n      \"Set *** to an instance of class %%%.\",\n    \"***.***(@@@)\":\n      \"From *** get the *** function, and call it with parameters self, @@@.\",\n    \"***.*** = '***'\":\n      \"From *** get the *** attribute and set it to '***'.\"\n}\n\n# do they want to drill phrases first\nPHRASE_FIRST = False\nif len(sys.argv) == 2 and sys.argv[1] == \"english\":\n    PHRASE_FIRST = True\n\n# load up the words from the website\nfor word in urlopen(WORD_URL).readlines():\n    WORDS.append(word.strip())\n\n\ndef convert(snippet, phrase):\n    class_names = [w.capitalize() for w in\n                   random.sample(WORDS, snippet.count(\"%%%\"))]\n    other_names = random.sample(WORDS, snippet.count(\"***\"))\n    results = []\n    param_names = []\n\n    for i in range(0, snippet.count(\"@@@\")):\n        param_count = random.randint(1,3)\n        param_names.append(', '.join(random.sample(WORDS, param_count)))\n\n    for sentence in snippet, phrase:\n        result = sentence[:]\n\n        # fake class names\n        for word in class_names:\n            result = result.replace(\"%%%\", word, 1)\n\n        # fake other names\n        for word in other_names:\n            result = result.replace(\"***\", word, 1)\n\n        # fake parameter lists\n        for word in param_names:\n            result = result.replace(\"@@@\", word, 1)\n\n        results.append(result)\n\n    return results\n\n\n# keep going until they hit CTRL-D\ntry:\n    while True:\n        snippets = PHRASES.keys()\n        random.shuffle(snippets)\n\n        for snippet in snippets:\n            phrase = PHRASES[snippet]\n            question, answer = convert(snippet, phrase)\n            if PHRASE_FIRST:\n                question, answer = answer, question\n\n            print question\n\n            raw_input(\"> \")\n            print \"ANSWER:  %s\\n\\n\" % answer\nexcept EOFError:\n    print \"\\nBye\"\n"
  },
  {
    "path": "Python2/ex42.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex42: Is-A, Has-A, Objects, and Classes\n\n## Animal is-a object (yes, sort of confusing) look at the extra credit\nclass Animal(object):\n    pass\n\n## Dog is-a Animal\nclass Dog(Animal):\n\n    def __init__(self, name):\n        ## Dog has-a name\n        self.name = name\n\n## Cat is-a animal\nclass Cat(Animal):\n\n    def __init__(self, name):\n        ## Cat has-a name\n        self.name = name\n\n## Person is-a object\nclass Person(object):\n\n    def __init__(self, name):\n        ## Person has-a name\n        self.name = name\n\n        ## Person has-a pet of some kind\n        self.pet = None\n\n## Employee is-a person\nclass Employee(Person):\n\n    def __init__(self, name, salary):\n        ## run the __init__ method of a parent class reliably\n        super(Employee, self).__init__(name)\n        ## Employee has-a salary\n        self.salary = salary\n\n## Fish is-a object\nclass Fish(object):\n    pass\n\n## Salmon is-a Fish\nclass Salmon(Fish):\n    pass\n\n## Halibut is-a fish\nclass Halibut(Fish):\n    pass\n\n## rover is-a Dog\nrover = Dog(\"Rover\")\n\n## satan is-a Cat\nsatan = Cat(\"Satan\")\n\n## mary is-a Person\nmary = Person(\"Mary\")\n\n## mary's pet is satan\nmary.pet = satan\n\n## frank is-a Employee, his salary is 120000\nfrank = Employee(\"Frank\", 120000)\n\n## frank's pet is rover\nfrank.pet = rover\n\n## flipper is-a Fish\nflipper = Fish()\n\n## crouse is-a Salmon\ncrouse = Salmon()\n\n## harry is-a Halibut\nharry = Halibut()\n\n"
  },
  {
    "path": "Python2/ex43.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex43: Basic Object-Oriented Analysis and Design\n\n# Class Hierarchy\n# * Map\n#   - next_scene\n#   - opening_scene\n# * Engine\n#   - play\n# * Scene\n#   - enter\n#   * Death\n#   * Central Corridor\n#   * Laser Weapon Armory\n#   * The Bridge\n#   * Escape Pod\n# * Human\n#   - attack\n#   - defend\n#   * Hero\n#   * Monster\n\nfrom sys import exit\nfrom random import randint\nimport time\nimport math\n\nclass Engine(object):\n\n    def __init__(self, scene_map, hero):\n        self.scene_map = scene_map\n        self.hero = hero\n\n    def play(self):\n        current_scene = self.scene_map.opening_scene()\n\n        while True:\n            print \"\\n--------\"\n            next_scene_name = current_scene.enter(self.hero)\n            current_scene = self.scene_map.next_scene(next_scene_name)\n\n\n\n\nclass Scene(object):\n\n    def enter(self):\n        print \"This scene is not yet configured. Subclass it and implement enter().\"\n        exit(1)\n\nclass Death(Scene):\n\n    quips = [\n        \"You died.  You kinda suck at this.\",\n         \"Your mom would be proud...if she were smarter.\",\n         \"Such a luser.\",\n         \"I have a small puppy that's better at this.\"\n    ]\n\n    def enter(self, hero):\n        print Death.quips[randint(0, len(self.quips)-1)]\n        exit(1)\n\nclass CentralCorridor(Scene):\n\n    def enter(self, hero):\n        print \"The Gothons of Planet Percal #25 have invaded your ship and destroyed\"\n        print \"your entire crew.  You are the last surviving member and your last\"\n        print \"mission is to get the neutron destruct bomb from the Weapons Armory,\"\n        print \"put it in the bridge, and blow the ship up after getting into an \"\n        print \"escape pod.\"\n        print \"\\n\"\n        print \"You're running down the central corridor to the Weapons Armory when\"\n        print \"a Gothon jumps out, red scaly skin, dark grimy teeth, and evil clown costume\"\n        print \"flowing around his hate filled body.  He's blocking the door to the\"\n        print \"Armory and about to pull a weapon to blast you.\"\n\n        action = raw_input(\"> \")\n\n        if action == \"shoot!\":\n            print \"Quick on the draw you yank out your blaster and fire it at the Gothon.\"\n            print \"His clown costume is flowing and moving around his body, which throws\"\n            print \"off your aim.  Your laser hits his costume but misses him entirely.  This\"\n            print \"completely ruins his brand new costume his mother bought him, which\"\n            print \"makes him fly into an insane rage and blast you repeatedly in the face until\"\n            print \"you are dead.  Then he eats you.\"\n            return 'death'\n\n        elif action == \"dodge!\":\n            print \"Like a world class boxer you dodge, weave, slip and slide right\"\n            print \"as the Gothon's blaster cranks a laser past your head.\"\n            print \"In the middle of your artful dodge your foot slips and you\"\n            print \"bang your head on the metal wall and pass out.\"\n            print \"You wake up shortly after only to die as the Gothon stomps on\"\n            print \"your head and eats you.\"\n            return 'death'\n\n        elif action == \"tell a joke\":\n            print \"Lucky for you they made you learn Gothon insults in the academy.\"\n            print \"You tell the one Gothon joke you know:\"\n            print \"Lbhe zbgure vf fb sng, jura fur fvgf nebhaq gur ubhfr, fur fvgf nebhaq gur ubhfr.\"\n            print \"The Gothon stops, tries not to laugh, then busts out laughing and can't move.\"\n            print \"While he's laughing you run up and shoot him square in the head\"\n            print \"putting him down, then jump through the Weapon Armory door.\"\n            return 'laser_weapon_armory'\n\n        else:\n            print \"DOES NOT COMPUTE!\"\n            return 'central_corridor'\n\nclass LaserWeaponArmory(Scene):\n\n    def enter(self, hero):\n        print \"You do a dive roll into the Weapon Armory, crouch and scan the room\"\n        print \"for more Gothons that might be hiding.  It's dead quiet, too quiet.\"\n        print \"You stand up and run to the far side of the room and find the\"\n        print \"neutron bomb in its container.  There's a keypad lock on the box\"\n        print \"and you need the code to get the bomb out.  If you get the code\"\n        print \"wrong 10 times then the lock closes forever and you can't\"\n        print \"get the bomb.  The code is 3 digits.\"\n        code = \"%d%d%d\" % (randint(1,9), randint(1,9), randint(1,9))\n\n        print code\n\n        guesses = 0\n\n        while guesses < 10:\n            guess = raw_input(\"[keypad]> \")\n            if guess == code:\n                break\n            print \"BZZZZEDDD!\"\n            guesses += 1\n\n        if guess == code:\n            print \"The container clicks open and the seal breaks, letting gas out.\"\n            print \"You grab the neutron bomb and run as fast as you can to the\"\n            print \"bridge where you must place it in the right spot.\"\n            return 'the_bridge'\n        else:\n            print \"The lock buzzes one last time and then you hear a sickening\"\n            print \"melting sound as the mechanism is fused together.\"\n            print \"You decide to sit there, and finally the Gothons blow up the\"\n            print \"ship from their ship and you die.\"\n            return 'death'\n\n\n\nclass TheBridge(Scene):\n\n    def enter(self, hero):\n        print \"You burst onto the Bridge with the netron destruct bomb\"\n        print \"under your arm and surprise 5 Gothons who are trying to\"\n        print \"take control of the ship.  Each of them has an even uglier\"\n        print \"clown costume than the last.  They haven't pulled their\"\n        print \"weapons out yet, as they see the active bomb under your\"\n        print \"arm and don't want to set it off.\"\n\n        action = raw_input(\"> \")\n\n        if action == \"throw the bomb\":\n            print \"In a panic you throw the bomb at the group of Gothons\"\n            print \"and make a leap for the door.  Right as you drop it a\"\n            print \"Gothon shoots you right in the back killing you.\"\n            print \"As you die you see another Gothon frantically try to disarm\"\n            print \"the bomb. You die knowing they will probably blow up when\"\n            print \"it goes off.\"\n            return 'death'\n\n        elif action == \"slowly place the bomb\":\n            print \"You point your blaster at the bomb under your arm\"\n            print \"and the Gothons put their hands up and start to sweat.\"\n            print \"You inch backward to the door, open it, and then carefully\"\n            print \"place the bomb on the floor, pointing your blaster at it.\"\n            print \"You then jump back through the door, punch the close button\"\n            print \"and blast the lock so the Gothons can't get out.\"\n            print \"Now that the bomb is placed you run to the escape pod to\"\n            print \"get off this tin can.\"\n            return 'escape_pod'\n        else:\n            print \"DOES NOT COMPUTE!\"\n            return \"the_bridge\"\n\n\nclass EscapePod(Scene):\n\n    def enter(self, hero):\n        print \"You rush through the ship desperately trying to make it to\"\n        print \"the escape pod before the whole ship explodes.  It seems like\"\n        print \"hardly any Gothons are on the ship, so your run is clear of\"\n        print \"interference.  You get to the chamber with the escape pods, and\"\n        print \"now need to pick one to take.  Some of them could be damaged\"\n        print \"but you don't have time to look.  There's 5 pods, which one\"\n        print \"do you take?\"\n\n        good_pod = randint(1,5)\n        print good_pod\n        guess = raw_input(\"[pod #]> \")\n\n\n        if int(guess) != good_pod:\n            print \"You jump into pod %s and hit the eject button.\" % guess\n            print \"The pod escapes out into the void of space, then\"\n            print \"implodes as the hull ruptures, crushing your body\"\n            print \"into jam jelly.\"\n            return 'death'\n        else:\n            print \"You jump into pod %s and hit the eject button.\" % guess\n            print \"The pod easily slides out into space heading to\"\n            print \"the planet below.  As it flies to the planet, you look\"\n            print \"back and see your ship implode then explode like a\"\n            print \"bright star, taking out the Gothon ship at the same\"\n            print \"time.  You won!\"\n\n            return 'final_fight'\n\nclass Win(Scene):\n    ''' Win '''\n\n    def enter(self, hero):\n\n        print '''\n        You Win! Good Job!\n        '''\n\n        exit(0)\n\nclass Final(Scene):\n\n    ''' final fight '''\n\n    def enter(self, hero):\n\n        # initialize a monster\n        monster = Monster(\"Gothon\")\n\n        print \"%s, You now came across the final boss %s! Let's fight!!!\" % (hero.name, monster.name)\n\n\n        a_combat = Combat()\n\n        next_stage = a_combat.combat(hero, monster)\n        return next_stage\n\nclass Combat(object):\n\n    def combat(self, hero, monster):\n\n        ''' combat between two roles '''\n\n        round = 1\n        while True:\n            print '='*30\n            print 'round %d' % round\n            print '='*30\n            print \"Your HP: %d\" % hero.hp\n            print \"%s's HP: %d\" % (monster.name, monster.hp)\n            print 'Which action do you want to take?'\n            print '-'*10\n            print '1) attack - Attack the enemy'\n            print '2) defend - Defend from being attacked, also will recover a bit'\n\n            try:\n                action = int(raw_input('> '))\n            except ValueError:\n                print \"Please enter a number!!\"\n                continue\n\n            # defending should be done before attacking\n            if action == 2:\n                hero.defend()\n\n            # action of monster, 1/5 possibility it will defends\n            monster_action = randint(1, 6)\n            if monster_action == 5:\n                monster.defend()\n\n            if action == 1:\n                hero.attack(monster)\n            elif action == 2:\n                pass\n            else:\n                print \"No such action!\"\n\n            if monster_action < 5:\n                monster.attack(hero)\n\n            # whether win or die\n            if hero.hp <= 0:\n                return 'death'\n\n            if monster.hp <= 0:\n                return 'win'\n\n            hero.rest()\n            monster.rest()\n\n            round += 1\n\nclass Map(object):\n\n    scenes = {\n        'central_corridor': CentralCorridor(),\n        'laser_weapon_armory': LaserWeaponArmory(),\n        'the_bridge': TheBridge(),\n        'escape_pod': EscapePod(),\n        'death': Death(),\n        'final_fight': Final(),\n        'win': Win()\n    }\n\n    def __init__(self, start_scene):\n        self.start_scene = start_scene\n\n    def next_scene(self, scene_name):\n        return Map.scenes.get(scene_name)\n\n    def opening_scene(self):\n        return self.next_scene(self.start_scene)\n\nclass Human(object):\n\n    ''' class for human '''\n    defending = 0\n\n    def __init__(self, name):\n        self.name = name\n\n    def attack(self, target):\n        ''' attack the target '''\n        percent = 0\n        time.sleep(1)\n        if target.defending == 1:\n            percent = float(self.power) / 10.0 + randint(0, 10)\n            target.hp = math.floor(target.hp - percent)\n        else:\n            percent = float(self.power) / 5.0 + randint(0, 10)\n            target.hp = math.floor(target.hp - percent)\n        print \"%s attack %s. %s's HP decreased by %d points.\" % (self.name, target.name, target.name, percent)\n\n    def defend(self):\n        ''' be in the defending state. '''\n        self.defending = 1\n        print \"%s is trying to defend.\" % self.name\n\n    def rest(self):\n        ''' recover a bit after each round '''\n        if self.defending == 1:\n            percent = self.rate * 10 + randint(0, 10)\n        else:\n            percent = self.rate * 2 + randint(0, 10)\n        self.hp += percent\n        print \"%s's HP increased by %d after rest.\" % (self.name, percent)\n        self.defending = 0\n\n\nclass Hero(Human):\n    ''' class for hero '''\n\n    hp = 1000\n    power = 200\n    rate = 5\n\nclass Monster(Human):\n    ''' class for monster '''\n    hp = 5000\n    power = 250\n    rate = 5\n\na_map = Map('central_corridor')\na_hero = Hero('Joe')\na_game = Engine(a_map, a_hero)\na_game.play()\n"
  },
  {
    "path": "Python2/ex44.py",
    "content": "#!/bin/python2\n# -*- coding: utf-8 -*-\n\n# ex44: Inheritance vs. Composition\n\nclass Other(object):\n\n    def override(self):\n        print \"OTHER override()\"\n\n    def implicit(self):\n        print \"OTHER implicit()\"\n\n    def altered(self):\n        print \"OTHER altered()\"\n\nclass Child(object):\n\n    def __init__(self):\n        self.other = Other()\n\n    def implicit(self):\n        self.other.implicit()\n\n    def override(self):\n        print \"CHILD override()\"\n\n    def altered(self):\n        print \"CHILD, BEFORE OTHER altered()\"\n        self.other.altered()\n        print \"CHILD, AFTER OTHER altered()\"\n\nson = Child()\n\nson.implicit()\nson.override()\nson.altered()\n"
  },
  {
    "path": "Python2/ex46/skeleton/NAME/__init__.py",
    "content": ""
  },
  {
    "path": "Python2/ex46/skeleton/setup.py",
    "content": "try:\n    from setuptools import setup\nexcept ImportError:\n    from distutils.core import setup\n\nconfig = {\n    'description': 'A tiny game',\n    'author': 'Joseph Pan',\n    'url': 'URL to get it at.',\n    'download_url': 'Where to download it.',\n    'author_email': 'cs.wzpan@gmail.com',\n    'version': '0.1',\n    'install_requires': ['nose'],\n    'packages': ['NAME'],\n    'scripts': [],\n    'name': 'projectname'\n}\n\nsetup(**config)\n"
  },
  {
    "path": "Python2/ex46/skeleton/tests/NAME_test.py",
    "content": "from nose.tools import *\nimport NAME\n\ndef setup():\n    print \"SETUP!\"\n\ndef teardown():\n    print \"TEAR DOWN!\"\n\ndef test_basic():\n    print \"I RAN!\"\n"
  },
  {
    "path": "Python2/ex46/skeleton/tests/__init__.py",
    "content": ""
  },
  {
    "path": "Python2/ex47/skeleton/ex47/__init__.py",
    "content": ""
  },
  {
    "path": "Python2/ex47/skeleton/ex47/game.py",
    "content": "class Room(object):\n\n    def __init__(self, name, description):\n        self.name = name\n        self.description = description\n        self.paths = {}\n\n    def go(self, direction):\n        return self.paths.get(direction, None)\n\n    def add_paths(self, paths):\n        self.paths.update(paths)\n"
  },
  {
    "path": "Python2/ex47/skeleton/setup.py",
    "content": "try:\n    from setuptools import setup\nexcept ImportError:\n    from distutils.core import setup\n\nconfig = {\n    'description': 'My Project',\n    'author': 'Joseph Pan',\n    'url': 'URL to get it at.',\n    'download_url': 'Where to download it.',\n    'author_email': 'cs.wzpan@gmail.com',\n    'version': '0.1',\n    'install_requires': ['nose'],\n    'packages': ['ex47'],\n    'scripts': [],\n    'name': 'projectname'\n}\n\nsetup(**config)\n"
  },
  {
    "path": "Python2/ex47/skeleton/tests/__init__.py",
    "content": ""
  },
  {
    "path": "Python2/ex47/skeleton/tests/ex47_test.py",
    "content": "from nose.tools import *\nfrom ex47.game import Room\n\ndef test_room():\n    gold = Room(\"GoldRoom\",\n                \"\"\" This room has gold in it you can grab. There's a \\\n    door to the north.\"\"\"\n                )\n    assert_equal(gold.name, \"GoldRoom\")\n    assert_equal(gold.paths, {})\n\ndef test_room_paths():\n    center = Room(\"Center\", \"Test room in the center.\")\n    north = Room(\"North\", \"Test room in the north.\")\n    south = Room(\"South\", \"Test room in the south.\")\n\n    center.add_paths({'north': north, 'south': south})\n    assert_equal(center.go('north'), north)\n    assert_equal(center.go('south'), south)\n    \ndef test_map():\n    start = Room(\"Start\", \"You can go west and down a hole.\")\n    west = Room(\"Trees\", \"There are trees here, you can go east.\")\n    down = Room(\"Dungeon\", \"It's dark down here, you can go up.\")\n\n    start.add_paths({'west': west, 'down': down})\n    west.add_paths({'east': start})\n    down.add_paths({'up': start})\n\n    assert_equal(start.go('west'), west)\n    assert_equal(start.go('west').go('east'), start)\n    assert_equal(start.go('down').go('up'), start)\n"
  },
  {
    "path": "Python2/ex48/skeleton/ex48/__init__.py",
    "content": ""
  },
  {
    "path": "Python2/ex48/skeleton/ex48/lexicon.py",
    "content": "class Lexicon(object):\n\n    def convert_number(s):\n        try:\n            return int(s)\n        except ValueError:\n            return None\n\n    def scan(s):\n        directions = ['north', 'south', 'west', 'east']\n        verbs = ['go', 'kill', 'eat']\n        stops = ['the', 'in', 'of']\n        nouns = ['bear', 'princess']\n\n        result = []\n\n        words = s.lower().split()\n\n        for word in words:\n            if word in directions:\n                result.append(('direction', word))\n            elif word in verbs:\n                result.append(('verb', word))\n            elif word in stops:\n                result.append(('stop', word))\n            elif word in nouns:\n                result.append(('noun', word))\n            elif Lexicon.convert_number(word):\n                result.append(('number', int(word)))\n            else:\n                result.append(('error', word))\n\n        return result\n"
  },
  {
    "path": "Python2/ex48/skeleton/setup.py",
    "content": "from distutils.core import setup\n\nsetup(\n    name = \"lexicon\",\n    packages = [\"ex48\"],\n    version = \"1.0\",\n    description = \"lexicon example\",\n    author = \"Joseph Pan\",\n    author_email = \"cs.wzpan@gmail.com\",\n    url = \"http://hahack.com/\",\n    download_url = \"\",\n    keywords = [\"lexicon\"],\n    classifiers = [\n        \"Programming Language :: Python\",\n        \"Programming Language :: Python :: 3\",\n        \"Development Status :: 4 - Beta\",\n        \"Environment :: Other Environment\",\n        \"Intended Audience :: Developers\",\n        \"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)\",\n        \"Operating System :: OS Independent\",\n        \"Topic :: Software Development :: Libraries :: Python Modules\",\n        \"Topic :: Text Processing :: Linguistic\",\n        ],\n    long_description = \"\"\"\n    Put a long description here.\n    \"\"\"\n    )\n"
  },
  {
    "path": "Python2/ex48/skeleton/test/__init__.py",
    "content": ""
  },
  {
    "path": "Python2/ex48/skeleton/test/lexicon_tests.py",
    "content": "from nose.tools import *\nfrom ex48 import lexicon\n\n\ndef text_directions():\n    assert_equal(lexicon.scan(\"north\"), [('direction', 'north')])\n    result = lexicon.scan(\"north South EAST west dOwn up left right back\")\n    assert_equal(result, [('direction', 'north'),\n                          ('direction', 'South'),\n                          ('direction', 'EAST'),\n                          ('direction', 'west'),\n                          ('direction', 'dOwn'),\n                          ('direction', 'up'),\n                          ('direction', 'left'),\n                          ('direction', 'right'),\n                          ('direction', 'back')\n                          ])\n\n\ndef test_verbs():\n    assert_equal(lexicon.scan(\"go\"), [('verb', 'go')])\n    result = lexicon.scan(\"go KILL eat stop\")\n    assert_equal(result, [('verb', 'go'),\n                          ('verb', 'KILL'),\n                          ('verb', 'eat'),\n                          ('verb', 'stop')\n                          ])\n\n\ndef test_stops():\n    assert_equal(lexicon.scan(\"the\"), [('stop', 'the')])\n    result = lexicon.scan(\"the in of FROM at it\")\n    assert_equal(result, [('stop', 'the'),\n                          ('stop', 'in'),\n                          ('stop', 'of'),\n                          ('stop', 'FROM'),\n                          ('stop', 'at'),\n                          ('stop', 'it'),\n                          ])\n\n\ndef test_numbers():\n    assert_equal(lexicon.scan(\"1234\"), [('number', '1234')])\n    result = lexicon.scan(\"3 91234 23098 8128 0\")\n    assert_equal(result, [('number', '3'),\n                          ('number', '91234'),\n                          ('number', '23098'),\n                          ('number', '8128'),\n                          ('number', '0'),\n                          ])\n\n\ndef test_errors():\n    assert_equal(lexicon.scan(\"ASDFADFASDF\"), [('error', 'ASDFADFASDF')])\n    result = lexicon.scan(\"Bear IAS princess\")\n    assert_equal(result, [('noun', 'Bear'),\n                          ('error', 'IAS'),\n                          ('noun', 'princess')\n                          ])\n"
  },
  {
    "path": "Python2/ex49/skeleton/ex49/__init__.py",
    "content": ""
  },
  {
    "path": "Python2/ex49/skeleton/ex49/parser.py",
    "content": "class ParserError(Exception):\n    pass\n\nclass Sentence(object):\n\n    def __init__(self, subject, verb, object):\n        # remember we take ('noun','princess') tuples and convert them\n        self.subject = subject[1]\n        self.verb = verb[1]\n        self.object = object[1]\n\n\ndef peek(word_list):\n    \n    if word_list:\n        word = word_list[0]\n        return word[0]\n    else:\n        return None\n\n\ndef match(word_list, expecting):\n    if word_list:\n        # notice the pop function here\n        word = word_list.pop(0)\n        if word[0] == expecting:\n            return word\n        else:\n            return None\n    else:\n        return None\n\n\ndef skip(word_list, word_type):\n    while peek(word_list) == word_type:\n        # remove words that belongs to word_type from word_list\n        match(word_list, word_type)\n\n\nclass Parser(object):\n\n    def parse_verb(self, word_list):\n        skip(word_list, 'stop')\n\n        if peek(word_list) == 'verb':\n            return match(word_list, 'verb')\n        else:\n            raise ParserError(\"Expected a verb next.\")\n\n\n    def parse_object(self, word_list):\n        skip(word_list, 'stop')\n        next = peek(word_list)\n\n        if next == 'noun':\n            return match(word_list, 'noun')\n        if next == 'direction':\n            return match(word_list, 'direction')\n        else:\n            raise ParserError(\"Expected a noun or direction next.\")\n\n\n    def parse_subject(self, word_list, subj):\n        verb = self.parse_verb(word_list)\n        obj = self.parse_object(word_list)\n\n        return Sentence(subj, verb, obj)\n\n\n    def parse_sentence(self, word_list):\n        skip(word_list, 'stop')\n\n        start = peek(word_list)\n\n        if start == 'noun':\n            subj = match(word_list, 'noun')\n            return self.parse_subject(word_list, subj)\n        elif start == 'verb':\n            # assume the subject is the player then\n            return self.parse_subject(word_list, ('noun', 'player'))\n        else:\n            raise ParserError(\"Must start with subject, object, or verb not: %s\" % start)\n"
  },
  {
    "path": "Python2/ex49/skeleton/setup.py",
    "content": "from distutils.core import setup\n\nsetup(\n    name = \"MakeSentences\",\n    packages = [\"ex49\"],\n    version = \"1.0\",\n    description = \"Making Sentences\",\n    author = \"Joseph Pan\",\n    author_email = \"cs.wzpan@gmail.com\",\n    url = \"http://hahack.com/\",\n    download_url = \"\",\n    keywords = [\"lexicon\"],\n    classifiers = [\n        \"Programming Language :: Python\",\n        \"Programming Language :: Python :: 3\",\n        \"Development Status :: 4 - Beta\",\n        \"Environment :: Other Environment\",\n        \"Intended Audience :: Developers\",\n        \"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)\",\n        \"Operating System :: OS Independent\",\n        \"Topic :: Software Development :: Libraries :: Python Modules\",\n        \"Topic :: Text Processing :: Linguistic\",\n        ],\n    long_description = \"\"\"\n    Put a long description here.\n    \"\"\"\n    )\n"
  },
  {
    "path": "Python2/ex49/skeleton/test/__init__.py",
    "content": ""
  },
  {
    "path": "Python2/ex49/skeleton/test/parser_test.py",
    "content": "from nose.tools import *\nfrom ex49.parser import *\nfrom ex48.lexicon import *\nfrom copy import deepcopy\n\n\n# construct a test set that consists of several test lists\nglobal_test_lists = [ scan('south'), scan('door'), scan('go'), scan('to'),\n                      scan('234'), scan('error123'), scan('the east door'), scan('go to east'),\n                      scan('bear go to the door'), scan('the princess kill 10 bears') \n                    ]\n\n# the type of the the first tuple for each test list\ntest_types = ['direction', 'noun', 'verb', 'stop', 'number', 'error',\n               'stop', 'verb', 'noun', 'stop', None]\n\nlist_len = len(global_test_lists)\n\n\ndef test_peek():\n    ''' test peek function '''\n    test_lists = deepcopy(global_test_lists)\n    for i in range(list_len):\n        test_list = test_lists[i]\n        expected_word = test_types[i]\n        assert_equal(peek(test_list), expected_word)\n\n\ndef test_match():\n    ''' test match function '''\n    test_lists = deepcopy(global_test_lists)\n    for i in range(list_len):\n        test_list = test_lists[i]\n        test_type = test_types[i]\n        if len(test_list) > 0:\n            expected_tuple = test_list[0]\n        else:\n            expected_tuple = None\n        assert_equal(match(test_list, test_type), expected_tuple)\n\n\n\ndef test_skip():\n    ''' test skip function '''\n    test_lists = deepcopy(global_test_lists)\n    expected_lists1 = [scan('south'), scan('door'), scan('go'), [], scan('234'), scan('error123'),\n                       scan('east door'), scan('go to east'), scan('bear go to the door'),\n                       scan('princess kill 10 bear'), []]\n\n    for i in range(list_len):\n        test_list = test_lists[i]\n        expected_list = expected_lists1[i]\n        skip(test_list, 'stop')\n        assert_equal(test_list, expected_list)\n\n    test_list2 = [('error', 'error123')]\n    expected_list2 = []\n    skip(test_list2, 'error')\n    assert_equal(test_list2, expected_list2)\n\n\n\ndef test_parse_verb():\n    ''' test parse_verb function '''\n    parser = Parser()\n    # test good situations\n    test_lists_good =  [scan('go'), scan('go to east'), scan('to error123 eat')] \n    \n    expected_lists = [scan('go'), scan('go'), scan('eat')]\n        \n    for i in range(len(test_lists_good)):\n        test_list = test_lists_good[i]\n        expected_list = expected_lists[i]\n        assert_equal(parser.parse_verb(test_list), *expected_list)\n    \n    # test bad situations\n    test_lists_bad = [scan('south'), scan('door'), scan('234'), scan('east door'),\n                       scan('error123'), scan('to'),\n                      scan('bear go to the door'), scan('the princess kill 10 bear'), []]\n    for i in range(len(test_lists_bad)):\n        test_list = test_lists_bad[i]\n        assert_raises(ParserError, parser.parse_verb, test_list)\n\n\ndef test_parse_num():\n    ''' test parse_num function '''\n    parser = Parser()\n    # test good situations\n    test_lists_good = [scan('302'), scan('to error123 302')]\n    expected_lists = [scan('302'), scan('302')]\n        \n    for i in range(len(test_lists_good)):\n        test_list = test_lists_good[i]\n        expected_list = expected_lists[i]\n        assert_equal(parser.parse_num(test_list), *expected_list)\n    \n    # test bad situations\n    test_lists_bad = [scan('south'), scan('door'), scan('to'), scan('error123'), scan('east door'),\n                      scan('bear go to the door'), scan('the princess kill 10 bear'),[]]\n    \n    \n    for i in range(len(test_lists_bad)):\n        test_list = test_lists_bad[i]\n        assert_equal(parser.parse_num(test_list), None)\n\n\ndef test_parse_object():\n    ''' test parse_object function '''\n    parser = Parser()\n    # test good situations\n    test_lists_good =  [scan('south'), scan('door'), scan('the bear'), scan('east door'),\n                        scan('bear go to the door'), scan('the princess kill 10 bear')]\n    \n    expected_lists = [scan('south'), scan('door'), scan('bear'),\n                      scan('east'), scan('bear'), scan('princess')]\n        \n    for i in range(len(test_lists_good)):\n        test_list = test_lists_good[i]\n        expected_list = expected_lists[i]\n        assert_equal(parser.parse_object(test_list), *expected_list)\n    \n    # test bad situations\n    test_lists_bad = [scan('go'), scan('to'), scan('234'), scan('error123'), scan('go to east'), []]\n    for i in range(len(test_lists_bad)):\n        test_list = test_lists_bad[i]\n        assert_raises(ParserError, parser.parse_object, test_list)\n        \n\ndef test_class_sentence():\n    # test good situations\n    test_lists_good =  [scan('bear go east'), scan('princess kill bear'), scan(\n                        'princess kill 10 bears')]\n\n    expected_nums = [1, 1, 10]\n    expected_objects = ['east', 'bear', 'bear']\n        \n    for i in range(len(test_lists_good)):\n        test_list = test_lists_good[i]\n        test_num = expected_nums[i]\n        test_object = expected_objects[i]\n        \n        sentence = Sentence(*test_list)\n        assert_equal(sentence.subject, test_list[0][1])\n        assert_equal(sentence.verb, test_list[1][1])\n        assert_equal(sentence.num, test_num)\n        assert_equal(sentence.object, test_object)\n        \n    # test bad situations, for more restrict checking\n    test_lists_bad =  [scan('south'), scan('bear'), scan('go'), scan('to'),\n                       scan('the'), scan('door'), scan('bear go to the door'),\n                       scan('the princess kill 10 bears'), []] \n\n    for i in range(len(test_lists_good)):\n        test_list = test_lists_bad[i]\n        assert_raises(TypeError, Sentence, *test_list)\n\n\ndef test_parse_subject():\n    ''' test parse_subject function '''\n    parser = Parser()\n    \n    test_lists =  [scan('error123 eat princess'), scan('go to east'),\n                   scan('go error123 to the carbinet door'), scan('kill 10 bears')]\n        \n    test_subjects = [scan('bear'), scan('princess'), scan('carbinet'), scan('princess')]\n    expected_verbs = ['eat', 'go', 'go', 'kill']\n    expected_objects = ['princess', 'east', 'carbinet', 'bear']\n    expected_nums = [1, 1, 1, 10]\n\n    for i in range(len(test_lists)):\n        test_list = test_lists[i]\n        test_subject = test_subjects[i]\n        expected_verb = expected_verbs[i]\n        expected_object = expected_objects[i]\n        expected_num = expected_nums[i]\n        sentence = parser.parse_subject(test_list, test_subject[0])        \n        assert_equal(sentence.subject, test_subject[0][1])\n        assert_equal(sentence.verb, expected_verb)\n        assert_equal(sentence.object, expected_object)\n        assert_equal(sentence.num, expected_num)\n\n\ndef test_parse_sentence():\n    ''' test parse_sentence function '''\n    parser = Parser()\n    # test good situations\n    test_lists1 =  [scan('bear go to the door'),\n                    scan('the princess kill 10 bears'),\n                    scan('kill the bear')]\n\n    expected_subjects = ['bear', 'princess', 'player']\n    expected_verbs = ['go', 'kill', 'kill']\n    expected_objects = ['door', 'bear', 'bear']\n    expected_nums = [1, 10, 1]\n        \n    for i in range(len(test_lists1)):\n        test_list = test_lists1[i]\n        sentence = parser.parse_sentence(test_list)\n        expected_subject = expected_subjects[i]\n        expected_verb = expected_verbs[i]\n        expected_object = expected_objects[i]\n        expected_num = expected_nums[i]\n        assert_equal(sentence.subject, expected_subject)\n        assert_equal(sentence.verb, expected_verb)\n        assert_equal(sentence.object, expected_object)\n        assert_equal(sentence.num, expected_num)\n\n    # test bad situations\n    test_lists2 =  [scan('234')]\n    for i in range(len(test_lists2)):\n        test_list = test_lists2[i]\n        assert_raises(ParserError, parser.parse_object, test_list)\n"
  },
  {
    "path": "Python2/game/skeleton/README",
    "content": "A little python site\n\n1) For Linux/MacOSX user\n\nPlease execute\n\n```\nexport PYTHONPATH=$PYTHONPATH:.\npython2 bin/app.py\n```\n\nthen visit <http://localhost:8080> to browse the site!\n\n1) For Windows user\n\nPlease execute\n\n```\n$env:PYTHONPATH = \"$env:PYTHONPATH;.\"\npython2 bin/app.py\n```\n\nthen visit <http://localhost:8080> to browse the site!\n"
  },
  {
    "path": "Python2/game/skeleton/bin/MultipartPostHandler.py",
    "content": "#!/usr/bin/python\n\n####\n# 02/2006 Will Holcomb <wholcomb@gmail.com>\n# \n# This library is free software; you can redistribute it and/or\n# modify it under the terms of the GNU Lesser General Public\n# License as published by the Free Software Foundation; either\n# version 2.1 of the License, or (at your option) any later version.\n# \n# This library is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n# Lesser General Public License for more details.\n#\n# 7/26/07 Slightly modified by Brian Schneider  \n# in order to support unicode files ( multipart_encode function )\n\"\"\"\nUsage:\n  Enables the use of multipart/form-data for posting forms\n\nInspirations:\n  Upload files in python:\n    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306\n  urllib2_file:\n    Fabien Seisen: <fabien@seisen.org>\n\nExample:\n  import MultipartPostHandler, urllib2, cookielib\n\n  cookies = cookielib.CookieJar()\n  opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies),\n                                MultipartPostHandler.MultipartPostHandler)\n  params = { \"username\" : \"bob\", \"password\" : \"riviera\",\n             \"file\" : open(\"filename\", \"rb\") }\n  opener.open(\"http://wwww.bobsite.com/upload/\", params)\n\nFurther Example:\n  The main function of this file is a sample which downloads a page and\n  then uploads it to the W3C validator.\n\"\"\"\n\nimport urllib\nimport urllib2\nimport mimetools, mimetypes\nimport os, stat\nfrom cStringIO import StringIO\n\nclass Callable:\n    def __init__(self, anycallable):\n        self.__call__ = anycallable\n\n# Controls how sequences are uncoded. If true, elements may be given multiple values by\n#  assigning a sequence.\ndoseq = 1\n\nclass MultipartPostHandler(urllib2.BaseHandler):\n    handler_order = urllib2.HTTPHandler.handler_order - 10 # needs to run first\n\n    def http_request(self, request):\n        data = request.get_data()\n        if data is not None and type(data) != str:\n            v_files = []\n            v_vars = []\n            try:\n                 for(key, value) in data.items():\n                     if type(value) == file:\n                         v_files.append((key, value))\n                     else:\n                         v_vars.append((key, value))\n            except TypeError:\n                systype, value, traceback = sys.exc_info()\n                raise TypeError, \"not a valid non-string sequence or mapping object\", traceback\n\n            if len(v_files) == 0:\n                data = urllib.urlencode(v_vars, doseq)\n            else:\n                boundary, data = self.multipart_encode(v_vars, v_files)\n\n                contenttype = 'multipart/form-data; boundary=%s' % boundary\n                if(request.has_header('Content-Type')\n                   and request.get_header('Content-Type').find('multipart/form-data') != 0):\n                    print \"Replacing %s with %s\" % (request.get_header('content-type'), 'multipart/form-data')\n                request.add_unredirected_header('Content-Type', contenttype)\n\n            request.add_data(data)\n        \n        return request\n\n    def multipart_encode(vars, files, boundary = None, buf = None):\n        if boundary is None:\n            boundary = mimetools.choose_boundary()\n        if buf is None:\n            buf = StringIO()\n        for(key, value) in vars:\n            buf.write('--%s\\r\\n' % boundary)\n            buf.write('Content-Disposition: form-data; name=\"%s\"' % key)\n            buf.write('\\r\\n\\r\\n' + value + '\\r\\n')\n        for(key, fd) in files:\n            file_size = os.fstat(fd.fileno())[stat.ST_SIZE]\n            filename = fd.name.split('/')[-1]\n            contenttype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'\n            buf.write('--%s\\r\\n' % boundary)\n            buf.write('Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"\\r\\n' % (key, filename))\n            buf.write('Content-Type: %s\\r\\n' % contenttype)\n            # buffer += 'Content-Length: %s\\r\\n' % file_size\n            fd.seek(0)\n            buf.write('\\r\\n' + fd.read() + '\\r\\n')\n        buf.write('--' + boundary + '--\\r\\n\\r\\n')\n        buf = buf.getvalue()\n        return boundary, buf\n    multipart_encode = Callable(multipart_encode)\n\n    https_request = http_request\n\ndef main():\n    import tempfile, sys\n\n    validatorURL = \"http://validator.w3.org/check\"\n    opener = urllib2.build_opener(MultipartPostHandler)\n\n    def validateFile(url):\n        temp = tempfile.mkstemp(suffix=\".html\")\n        os.write(temp[0], opener.open(url).read())\n        params = { \"ss\" : \"0\",            # show source\n                   \"doctype\" : \"Inline\",\n                   \"uploaded_file\" : open(temp[1], \"rb\") }\n        print opener.open(validatorURL, params).read()\n        os.remove(temp[1])\n\n    if len(sys.argv[1:]) > 0:\n        for arg in sys.argv[1:]:\n            validateFile(arg)\n    else:\n        validateFile(\"http://www.google.com\")\n\nif __name__==\"__main__\":\n    main()\n"
  },
  {
    "path": "Python2/game/skeleton/bin/__init__.py",
    "content": ""
  },
  {
    "path": "Python2/game/skeleton/bin/app.py",
    "content": "import web \nimport datetime\nimport os\n\nfrom bin import map\n\nurls = (\n    '/', 'Index',\n    '/hello', 'SayHello',\n    '/image', 'Upload',\n    '/game', 'GameEngine',\n    '/entry', 'Entry'\n    )\n\napp = web.application(urls, locals())\n\n# little hack so that debug mode works with sessions\nif web.config.get('_session') is None:\n    store = web.session.DiskStore('sessions')\n    session = web.session.Session(app, store,\n                                  initializer={'room': None, 'name': 'Jedi'})\n    web.config._session = session\nelse:\n    session = web.config._session\n    \nrender = web.template.render('templates/', base=\"layout\")\n\nclass Index:\n    def GET(self):\n        return render.index()\n\n\nclass SayHello:\n    def GET(self):\n        return render.hello_form()\n    def POST(self):\n        form = web.input(name=\"Nobody\", greet=\"hello\")\n        if form.name == '':\n            form.name = \"Nobody\"\n        if form.greet == '':\n            form.greet = \"Hello\"\n        greeting = \"%s, %s\" % (form.greet, form.name)\n        return render.hello(greeting = greeting)\n\n\nclass Upload:\n    ''' using cgi to upload and show image '''\n    def GET(self):\n        return render.upload_form()\n    def POST(self):\n        form = web.input(myfile={})\n        # web.debug(form['myfile'].file.read())\n        # get the folder name\n        upload_time = datetime.datetime.now().strftime(\"%Y-%m-%d\")\n        # create the folder\n        folder = os.path.join('./static', upload_time)\n        if not os.access(folder, 1):\n            os.mkdir(folder)\n        # get the file name\n        filename = os.path.join(folder, form['myfile'].filename)\n        print(type(form['myfile']))\n        with open(filename, 'wb') as f:\n            f.write(form['myfile'].file.read())\n            f.close()\n        return render.show(filename = filename)\n\n\nclass count:\n    def GET(self):\n        session.count += 1\n        return str(session.count)\n\n\nclass reset:\n    def GET(self):\n        session.kill()\n        return \"\"\n\n\nclass Entry(object):\n    def GET(self):\n        return render.entry()\n    def POST(self):\n        form = web.input(name=\"Jedi\")\n        if form.name != '':\n            session.name = form.name\n        session.room = map.START\n        #session.description = session.room.description\n        web.seeother(\"/game\")\n    \n\nclass GameEngine(object):\n\n    def GET(self):\n        if session.room:\n            return render.show_room(room=session.room, name=session.name)\n        else:\n            # why is there here? do you need it?\n            return render.you_died()\n\n    def POST(self):\n        form = web.input(action=None)\n\n        # there is a bug here, can you fix it?\n        web.debug(session.room.name)\n        if session.room and session.room.name != \"The End\" and form.action:\n            session.room = session.room.go(form.action)\n\n        web.seeother(\"/game\")\n\nif __name__ == \"__main__\":\n    app.run()\n"
  },
  {
    "path": "Python2/game/skeleton/bin/map.py",
    "content": "from random import randint\n\nclass RoomError(Exception):\n    pass\n\nclass Room(object):\n\n    def __init__(self, name, description):\n        self.name = name\n        self.description = description\n        self.paths = {}\n\n    def go(self, direction):\n        return self.paths.get(direction, None)\n\n    def add_paths(self, paths):\n        self.paths.update(paths)\n\n\ncentral_corridor = Room(\"Central Corridor\",\n\"\"\"\nThe Gothons of Planet Percal #25 have invaded your ship and destroyed\nyour entire crew.  You are the last surviving member and your last\nmission is to get the neutron destruct bomb from the Weapons Armory,\nput it in the bridge, and blow the ship up after getting into an \nescape pod.\n\nYou're running down the central corridor to the Weapons Armory when\na Gothon jumps out, red scaly skin, dark grimy teeth, and evil clown costume\nflowing around his hate filled body.  He's blocking the door to the\nArmory and about to pull a weapon to blast you.\n\"\"\"                        \n                        )\n\n\nlaser_weapon_armory = Room(\"Laser Weapon Armory\",\n\"\"\"\nLucky for you they made you learn Gothon insults in the academy.\nYou tell the one Gothon joke you know:\nLbhe zbgure vf fb sng, jura fur fvgf nebhaq gur ubhfr, fur fvgf nebhaq gur ubhfr.\nThe Gothon stops, tries not to laugh, then busts out laughing and can't move.\nWhile he's laughing you run up and shoot him square in the head\nputting him down, then jump through the Weapon Armory door.\n\nYou do a dive roll into the Weapon Armory, crouch and scan the room\nfor more Gothons that might be hiding.  It's dead quiet, too quiet.\nYou stand up and run to the far side of the room and find the\nneutron bomb in its container.  There's a keypad lock on the box\nand you need the code to get the bomb out.  If you get the code\nwrong 10 times then the lock closes forever and you can't\nget the bomb.  The code is 3 digits.\n\"\"\"\n)\n\n\nthe_bridge = Room(\"The Bridge\",\n\"\"\"\nThe container clicks open and the seal breaks, letting gas out.\nYou grab the neutron bomb and run as fast as you can to the\nbridge where you must place it in the right spot.\n\nYou burst onto the Bridge with the netron destruct bomb\nunder your arm and surprise 5 Gothons who are trying to\ntake control of the ship.  Each of them has an even uglier\nclown costume than the last.  They haven't pulled their\nweapons out yet, as they see the active bomb under your\narm and don't want to set it off.\n\"\"\")\n\n\nescape_pod = Room(\"Escape Pod\",\n\"\"\"\nYou point your blaster at the bomb under your arm\nand the Gothons put their hands up and start to sweat.\nYou inch backward to the door, open it, and then carefully\nplace the bomb on the floor, pointing your blaster at it.\nYou then jump back through the door, punch the close button\nand blast the lock so the Gothons can't get out.\nNow that the bomb is placed you run to the escape pod to\nget off this tin can.\n\nYou rush through the ship desperately trying to make it to\nthe escape pod before the whole ship explodes.  It seems like\nhardly any Gothons are on the ship, so your run is clear of\ninterference.  You get to the chamber with the escape pods, and\nnow need to pick one to take.  Some of them could be damaged\nbut you don't have time to look.  There's 5 pods, which one\ndo you take?\n\"\"\")\n\n\nthe_end_winner = Room(\"The End\",\n\"\"\"\nYou jump into pod 2 and hit the eject button.\nThe pod easily slides out into space heading to\nthe planet below.  As it flies to the planet, you look\nback and see your ship implode then explode like a\nbright star, taking out the Gothon ship at the same\ntime.  You won!\n\"\"\")\n\n\nthe_end_loser = Room(\"The End\",\n\"\"\"\nYou jump into a random pod and hit the eject button.\nThe pod escapes out into the void of space, then\nimplodes as the hull ruptures, crushing your body\ninto jam jelly.\n\"\"\"\n)\n\n\n\ngeneric_death = Room(\"death\", \"You died\")\n\n\nescape_pod.add_paths({\n    '2': the_end_winner,\n    '*': the_end_loser\n    })\n\n\nthe_bridge.add_paths({\n    'throw the bomb': generic_death,\n    'slowly place the bomb': escape_pod\n})\n\n\nlaser_weapon_armory.add_paths({\n    '0132': the_bridge,\n    '*': generic_death\n})\n\n\ncentral_corridor.add_paths({\n    'shoot!': generic_death,\n    'dodge!': generic_death,\n    'tell a joke': laser_weapon_armory\n})\n\n\nSTART = central_corridor\n"
  },
  {
    "path": "Python2/game/skeleton/setup.py",
    "content": "try:\n    from setuptools import setup\nexcept ImportError:\n    from distutils.core import setup\n\nconfig = {\n    'description': 'My Project',\n    'author': 'Joseph Pan',\n    'url': 'URL to get it at.',\n    'download_url': 'Where to download it.',\n    'author_email': 'cs.wzpan@gmail.com',\n    'version': '0.1',\n    'install_requires': ['nose'],\n    'packages': ['ex47'],\n    'scripts': [],\n    'name': 'projectname'\n}\n\nsetup(**config)\n"
  },
  {
    "path": "Python2/game/skeleton/static/css/marketing.css",
    "content": "* {\n    -webkit-box-sizing: border-box;\n    -moz-box-sizing: border-box;\n    box-sizing: border-box;\n}\n\nbody {\n    margin: 0 auto;\n    line-height: 1.7em;\n}\n\n.l-box {\n    padding: 1em;\n}\n\n.header {\n    margin: 0 0;\n}\n\n    .header .pure-menu {\n        padding: 0.5em;\n    }\n\n        .header .pure-menu li a:hover,\n        .header .pure-menu li a:focus {\n            background: none;\n            border: none;\n            color: #aaa;\n        }\n\nbody .primary-button {\n    background: #02a6eb;\n    color: #fff;\n}\n\n.splash {\n    margin: 2em auto 0;\n    padding: 3em 0.5em;\n    background: #eee;\n}\n    .splash .splash-head {\n        font-size: 300%;\n        margin: 0em 0;\n        line-height: 1.2em;\n    }\n    .splash .splash-subhead {\n        color: #999;\n        font-weight: 300;\n        line-height: 1.4em;\n    }\n    .splash .primary-button {\n        font-size: 150%;\n    }\n\n\n.content .content-subhead {\n    color: #999;\n    padding-bottom: 0.3em;\n    text-transform: uppercase;\n    margin: 0;\n    border-bottom: 2px solid #eee;\n    display: inline-block;\n}\n\n.content .content-ribbon {\n    margin: 3em;\n    border-bottom: 1px solid #eee;\n}\n\n.ribbon {\n    background: #eee;\n    text-align: center;\n    padding: 2em;\n    color: #999;\n}\n    .ribbon h2 {\n        display: inline;\n        font-weight: normal;\n    }\n\n.footer {\n    background: #111;\n    color: #666;\n    text-align: center;\n    padding: 1em;\n    font-size: 80%;\n}\n\n.pure-button-success,\n.pure-button-error,\n.pure-button-warning,\n.pure-button-secondary {\n  color: white;\n  border-radius: 4px;\n  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);\n}\n\n.pure-button-success {\n  background: rgb(28, 184, 65); /* this is a green */\n}\n\n.pure-button-error {\n  background: rgb(202, 60, 60); /* this is a maroon */\n}\n\n.pure-button-warning {\n  background: rgb(223, 117, 20); /* this is an orange */\n}\n\n.pure-button-secondary {\n  background: rgb(66, 184, 221); /* this is a light blue */\n}\n\n.content .content-quote {\n        font-family: \"Georgia\", serif;\n        color: #666;\n        font-style: italic;\n        line-height: 1.8em;\n        border-left: 5px solid #ddd;\n        padding-left: 1.5em;\n    }"
  },
  {
    "path": "Python2/game/skeleton/static/css/modal.css",
    "content": "/*!\n * Bootstrap v2.3.2\n *\n * Copyright 2012 Twitter, Inc\n * Licensed under the Apache License v2.0\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Designed and built with all the love in the world @twitter by @mdo and @fat.\n */\n\n.modal-backdrop {\n  position: fixed;\n  top: 0;\n  right: 0;\n  bottom: 0;\n  left: 0;\n  z-index: 1040;\n  background-color: #000000;\n}\n\n.modal-backdrop.fade {\n  opacity: 0;\n}\n\n.modal-backdrop,\n.modal-backdrop.fade.in {\n  opacity: 0.8;\n  filter: alpha(opacity=80);\n}\n\n.modal {\n  position: fixed;\n  top: 10%;\n  left: 50%;\n  z-index: 1050;\n  width: 560px;\n  margin-left: -280px;\n  background-color: #ffffff;\n  border: 1px solid #999;\n  border: 1px solid rgba(0, 0, 0, 0.3);\n  *border: 1px solid #999;\n  -webkit-border-radius: 6px;\n     -moz-border-radius: 6px;\n          border-radius: 6px;\n  outline: none;\n  -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);\n     -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);\n          box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);\n  -webkit-background-clip: padding-box;\n     -moz-background-clip: padding-box;\n          background-clip: padding-box;\n}\n\n.modal.fade {\n  top: -25%;\n  -webkit-transition: opacity 0.3s linear, top 0.3s ease-out;\n     -moz-transition: opacity 0.3s linear, top 0.3s ease-out;\n       -o-transition: opacity 0.3s linear, top 0.3s ease-out;\n          transition: opacity 0.3s linear, top 0.3s ease-out;\n}\n\n.modal.fade.in {\n  top: 10%;\n}\n\n.modal-header {\n  padding: 9px 15px;\n  border-bottom: 1px solid #eee;\n}\n\n.modal-header .close {\n  margin-top: 2px;\n}\n\n.modal-header h3 {\n  margin: 0;\n  line-height: 30px;\n}\n\n.modal-body {\n  position: relative;\n  max-height: 400px;\n  padding: 15px;\n  overflow-y: auto;\n}\n\n.modal-form {\n  margin-bottom: 0;\n}\n\n.modal-footer {\n  padding: 14px 15px 15px;\n  margin-bottom: 0;\n  text-align: right;\n  background-color: #f5f5f5;\n  border-top: 1px solid #ddd;\n  -webkit-border-radius: 0 0 6px 6px;\n     -moz-border-radius: 0 0 6px 6px;\n          border-radius: 0 0 6px 6px;\n  *zoom: 1;\n  -webkit-box-shadow: inset 0 1px 0 #ffffff;\n     -moz-box-shadow: inset 0 1px 0 #ffffff;\n          box-shadow: inset 0 1px 0 #ffffff;\n}\n\n.modal-footer:before,\n.modal-footer:after {\n  display: table;\n  line-height: 0;\n  content: \"\";\n}\n\n.modal-footer:after {\n  clear: both;\n}\n\n.modal-footer .btn + .btn {\n  margin-bottom: 0;\n  margin-left: 5px;\n}\n\n.modal-footer .btn-group .btn + .btn {\n  margin-left: -1px;\n}\n\n.modal-footer .btn-block + .btn-block {\n  margin-left: 0;\n}\n\n.hide {\n  display: none;\n}\n\n.show {\n  display: block;\n}\n\n.fade {\n  opacity: 0;\n  -webkit-transition: opacity 0.15s linear;\n     -moz-transition: opacity 0.15s linear;\n       -o-transition: opacity 0.15s linear;\n          transition: opacity 0.15s linear;\n}\n\n.fade.in {\n  opacity: 1;\n}\n"
  },
  {
    "path": "Python2/game/skeleton/static/css/pure-min.css",
    "content": "/*!\nPure v0.2.1\nCopyright 2013 Yahoo! Inc. All rights reserved.\nLicensed under the BSD License.\nhttps://github.com/yui/pure/blob/master/LICENSE.md\n*/\n/*!\nnormalize.css v1.1.2 | MIT License | git.io/normalize\nCopyright (c) Nicolas Gallagher and Jonathan Neal\n*/\n/*! normalize.css v1.1.2 | MIT License | git.io/normalize */article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none;height:0}[hidden]{display:none}html{font-size:100%;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}html,button,input,select,textarea{font-family:sans-serif}body{margin:0}a:focus{outline:thin dotted}a:active,a:hover{outline:0}h1{font-size:2em;margin:.67em 0}h2{font-size:1.5em;margin:.83em 0}h3{font-size:1.17em;margin:1em 0}h4{font-size:1em;margin:1.33em 0}h5{font-size:.83em;margin:1.67em 0}h6{font-size:.67em;margin:2.33em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}blockquote{margin:1em 40px}dfn{font-style:italic}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}mark{background:#ff0;color:#000}p,pre{margin:1em 0}code,kbd,pre,samp{font-family:monospace,serif;_font-family:'courier new',monospace;font-size:1em}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word}q{quotes:none}q:before,q:after{content:'';content:none}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}dl,menu,ol,ul{margin:1em 0}dd{margin:0 0 0 40px}menu,ol,ul{padding:0 0 0 40px}nav ul,nav ol{list-style:none;list-style-image:none}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}form{margin:0}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0;white-space:normal;*margin-left:-7px}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input{line-height:normal}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0;*height:13px;*width:13px}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}\n.pure-button{display:inline-block;*display:inline;zoom:1;line-height:normal;white-space:nowrap;vertical-align:baseline;text-align:center;cursor:pointer;-webkit-user-drag:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.pure-button::-moz-focus-inner{padding:0;border:0}.pure-button{font-size:100%;*font-size:90%;*overflow:visible;padding:.5em 1.5em;color:#444;color:rgba(0,0,0,.8);*color:#444;border:1px solid #999;border:0 rgba(0,0,0,0);background-color:#E6E6E6;text-decoration:none;border-radius:2px;-webkit-font-smoothing:antialiased;-webkit-transition:.1s linear -webkit-box-shadow;-moz-transition:.1s linear -moz-box-shadow;-ms-transition:.1s linear box-shadow;-o-transition:.1s linear box-shadow;transition:.1s linear box-shadow}.pure-button-hover,.pure-button:hover,.pure-button:focus{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#1a000000', GradientType=0);background-image:-webkit-gradient(linear,0 0,0 100%,from(transparent),color-stop(40%,rgba(0,0,0,.05)),to(rgba(0,0,0,.1)));background-image:-webkit-linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1));background-image:-moz-linear-gradient(top,rgba(0,0,0,.05) 0,rgba(0,0,0,.1));background-image:-ms-linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1));background-image:-o-linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1));background-image:linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1))}.pure-button:focus{outline:0}.pure-button-active,.pure-button:active{box-shadow:0 0 0 1px rgba(0,0,0,.15) inset,0 0 6px rgba(0,0,0,.2) inset}.pure-button[disabled],.pure-button-disabled,.pure-button-disabled:hover,.pure-button-disabled:focus,.pure-button-disabled:active{border:0;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);filter:alpha(opacity=40);-khtml-opacity:.4;-moz-opacity:.4;opacity:.4;cursor:not-allowed;box-shadow:none}.pure-button-hidden{display:none}.pure-button::-moz-focus-inner{padding:0;border:0}.pure-button-primary,.pure-button-selected,a.pure-button-primary,a.pure-button-selected{background-color:#0078e7;color:#fff}\n.pure-form{margin:0}.pure-form fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}.pure-form legend{border:0;padding:0;white-space:normal;*margin-left:-7px}.pure-form button,.pure-form input,.pure-form select,.pure-form textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}.pure-form button,.pure-form input{line-height:normal}.pure-form button,.pure-form input[type=button],.pure-form input[type=reset],.pure-form input[type=submit]{-webkit-appearance:button;cursor:pointer;*overflow:visible}.pure-form button[disabled],.pure-form input[disabled]{cursor:default}.pure-form input[type=checkbox],.pure-form input[type=radio]{box-sizing:border-box;padding:0;*height:13px;*width:13px}.pure-form input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}.pure-form input[type=search]::-webkit-search-cancel-button,.pure-form input[type=search]::-webkit-search-decoration{-webkit-appearance:none}.pure-form button::-moz-focus-inner,.pure-form input::-moz-focus-inner{border:0;padding:0}.pure-form textarea{overflow:auto;vertical-align:top}.pure-form input[type=text],.pure-form input[type=password],.pure-form input[type=email],.pure-form input[type=url],.pure-form input[type=date],.pure-form input[type=month],.pure-form input[type=time],.pure-form input[type=datetime],.pure-form input[type=datetime-local],.pure-form input[type=week],.pure-form input[type=number],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=color],.pure-form select,.pure-form textarea{padding:.5em .6em;display:inline-block;border:1px solid #ccc;font-size:.8em;box-shadow:inset 0 1px 3px #ddd;border-radius:4px;-webkit-transition:.3s linear border;-moz-transition:.3s linear border;-ms-transition:.3s linear border;-o-transition:.3s linear border;transition:.3s linear border;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-font-smoothing:antialiased}.pure-form input[type=text]:focus,.pure-form input[type=password]:focus,.pure-form input[type=email]:focus,.pure-form input[type=url]:focus,.pure-form input[type=date]:focus,.pure-form input[type=month]:focus,.pure-form input[type=time]:focus,.pure-form input[type=datetime]:focus,.pure-form input[type=datetime-local]:focus,.pure-form input[type=week]:focus,.pure-form input[type=number]:focus,.pure-form input[type=search]:focus,.pure-form input[type=tel]:focus,.pure-form input[type=color]:focus,.pure-form select:focus,.pure-form textarea:focus{outline:0;outline:thin dotted \\9;border-color:#129FEA}.pure-form input[type=file]:focus,.pure-form input[type=radio]:focus,.pure-form input[type=checkbox]:focus{outline:thin dotted #333;outline:1px auto #129FEA}.pure-form .pure-checkbox,.pure-form .pure-radio{margin:.5em 0;display:block}.pure-form input[type=text][disabled],.pure-form input[type=password][disabled],.pure-form input[type=email][disabled],.pure-form input[type=url][disabled],.pure-form input[type=date][disabled],.pure-form input[type=month][disabled],.pure-form input[type=time][disabled],.pure-form input[type=datetime][disabled],.pure-form input[type=datetime-local][disabled],.pure-form input[type=week][disabled],.pure-form input[type=number][disabled],.pure-form input[type=search][disabled],.pure-form input[type=tel][disabled],.pure-form input[type=color][disabled],.pure-form select[disabled],.pure-form textarea[disabled]{cursor:not-allowed;background-color:#eaeded;color:#cad2d3}.pure-form input[readonly],.pure-form select[readonly],.pure-form textarea[readonly],.pure-form input[readonly]:focus,.pure-form select[readonly]:focus,.pure-form textarea[readonly]:focus{background:#eee;color:#777;border-color:#ccc}.pure-form input:focus:invalid,.pure-form textarea:focus:invalid,.pure-form select:focus:invalid{color:#b94a48;border:1px solid #ee5f5b}.pure-form input:focus:invalid:focus,.pure-form textarea:focus:invalid:focus,.pure-form select:focus:invalid:focus{border-color:#e9322d}.pure-form input[type=file]:focus:invalid:focus,.pure-form input[type=radio]:focus:invalid:focus,.pure-form input[type=checkbox]:focus:invalid:focus{outline-color:#e9322d}.pure-form select{border:1px solid #ccc;background-color:#fff}.pure-form select[multiple]{height:auto}.pure-form label{margin:.5em 0 .2em;font-size:90%}.pure-form fieldset{margin:0;padding:.35em 0 .75em;border:0}.pure-form legend{display:block;width:100%;padding:.3em 0;margin-bottom:.3em;font-size:125%;color:#333;border-bottom:1px solid #e5e5e5}.pure-form-stacked input[type=text],.pure-form-stacked input[type=password],.pure-form-stacked input[type=email],.pure-form-stacked input[type=url],.pure-form-stacked input[type=date],.pure-form-stacked input[type=month],.pure-form-stacked input[type=time],.pure-form-stacked input[type=datetime],.pure-form-stacked input[type=datetime-local],.pure-form-stacked input[type=week],.pure-form-stacked input[type=number],.pure-form-stacked input[type=search],.pure-form-stacked input[type=tel],.pure-form-stacked input[type=color],.pure-form-stacked select,.pure-form-stacked label,.pure-form-stacked textarea{display:block;margin:.25em 0}.pure-form-aligned input,.pure-form-aligned textarea,.pure-form-aligned select,.pure-form-aligned .pure-help-inline,.pure-form-message-inline{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.pure-form-aligned .pure-control-group{margin-bottom:.5em}.pure-form-aligned .pure-control-group label{text-align:right;display:inline-block;vertical-align:middle;width:10em;margin:0 1em 0 0}.pure-form-aligned .pure-controls{margin:1.5em 0 0 10em}.pure-form input.pure-input-rounded,.pure-form .pure-input-rounded{border-radius:2em;padding:.5em 1em}.pure-form .pure-group fieldset{margin-bottom:10px}.pure-form .pure-group input{display:block;padding:10px;margin:0;border-radius:0;position:relative;top:-1px}.pure-form .pure-group input:focus{z-index:2}.pure-form .pure-group input:first-child{top:1px;border-radius:4px 4px 0 0}.pure-form .pure-group input:last-child{top:-2px;border-radius:0 0 4px 4px}.pure-form .pure-group button{margin:.35em 0}.pure-form .pure-input-1{width:100%}.pure-form .pure-input-2-3{width:66%}.pure-form .pure-input-1-2{width:50%}.pure-form .pure-input-1-3{width:33%}.pure-form .pure-input-1-4{width:25%}.pure-form .pure-help-inline,.pure-form-message-inline{display:inline-block;padding-left:.3em;color:#666;vertical-align:middle;font-size:90%}.pure-form-message{display:block;color:#666;font-size:90%}@media only screen and (max-width :480px){.pure-form button[type=submit]{margin:.7em 0 0}.pure-form input[type=text],.pure-form input[type=password],.pure-form input[type=email],.pure-form input[type=url],.pure-form input[type=date],.pure-form input[type=month],.pure-form input[type=time],.pure-form input[type=datetime],.pure-form input[type=datetime-local],.pure-form input[type=week],.pure-form input[type=number],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=color],.pure-form label{margin-bottom:.3em;display:block}.pure-group input[type=text],.pure-group input[type=password],.pure-group input[type=email],.pure-group input[type=url],.pure-group input[type=date],.pure-group input[type=month],.pure-group input[type=time],.pure-group input[type=datetime],.pure-group input[type=datetime-local],.pure-group input[type=week],.pure-group input[type=number],.pure-group input[type=search],.pure-group input[type=tel],.pure-group input[type=color]{margin-bottom:0}.pure-form-aligned .pure-control-group label{margin-bottom:.3em;text-align:left;display:block;width:100%}.pure-form-aligned .pure-controls{margin:1.5em 0 0}.pure-form .pure-help-inline,.pure-form-message-inline,.pure-form-message{display:block;font-size:80%;padding:.2em 0 .8em}}\n.pure-g{letter-spacing:-.31em;*letter-spacing:normal;*word-spacing:-.43em;text-rendering:optimizespeed}.opera-only :-o-prefocus,.pure-g{word-spacing:-.43em}.pure-u{display:inline-block;*display:inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-1,.pure-u-1-2,.pure-u-1-3,.pure-u-2-3,.pure-u-1-4,.pure-u-3-4,.pure-u-1-5,.pure-u-2-5,.pure-u-3-5,.pure-u-4-5,.pure-u-1-6,.pure-u-5-6,.pure-u-1-8,.pure-u-3-8,.pure-u-5-8,.pure-u-7-8,.pure-u-1-12,.pure-u-5-12,.pure-u-7-12,.pure-u-11-12,.pure-u-1-24,.pure-u-5-24,.pure-u-7-24,.pure-u-11-24,.pure-u-13-24,.pure-u-17-24,.pure-u-19-24,.pure-u-23-24{display:inline-block;*display:inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-1{width:100%}.pure-u-1-2{width:50%}.pure-u-1-3{width:33.33333%}.pure-u-2-3{width:66.66666%}.pure-u-1-4{width:25%}.pure-u-3-4{width:75%}.pure-u-1-5{width:20%}.pure-u-2-5{width:40%}.pure-u-3-5{width:60%}.pure-u-4-5{width:80%}.pure-u-1-6{width:16.666%}.pure-u-5-6{width:83.33%}.pure-u-1-8{width:12.5%}.pure-u-3-8{width:37.5%}.pure-u-5-8{width:62.5%}.pure-u-7-8{width:87.5%}.pure-u-1-12{width:8.3333%}.pure-u-5-12{width:41.6666%}.pure-u-7-12{width:58.3333%}.pure-u-11-12{width:91.6666%}.pure-u-1-24{width:4.1666%}.pure-u-5-24{width:20.8333%}.pure-u-7-24{width:29.1666%}.pure-u-11-24{width:45.8333%}.pure-u-13-24{width:54.1666%}.pure-u-17-24{width:70.8333%}.pure-u-19-24{width:79.1666%}.pure-u-23-24{width:95.8333%}.pure-g-r{letter-spacing:-.31em;*letter-spacing:normal;*word-spacing:-.43em}.opera-only :-o-prefocus,.pure-g-r{word-spacing:-.43em}.pure-g-r img{max-width:100%}@media (min-width:980px){.pure-visible-phone{display:none}.pure-visible-tablet{display:none}.pure-hidden-desktop{display:none}}@media (max-width:480px){.pure-g-r>.pure-u,.pure-g-r>[class *=\"pure-u-\"]{width:100%}}@media (max-width:767px){.pure-g-r>.pure-u,.pure-g-r>[class *=\"pure-u-\"]{width:100%}.pure-hidden-phone{display:none}.pure-visible-desktop{display:none}}@media (min-width:768px) and (max-width:979px){.pure-hidden-tablet{display:none}.pure-visible-desktop{display:none}}\n.pure-menu ul{position:absolute;visibility:hidden}.pure-menu.pure-menu-open{visibility:visible;z-index:2;width:100%}.pure-menu ul{left:-10000px;list-style:none;margin:0;padding:0;top:-10000px;z-index:1}.pure-menu>ul{position:relative}.pure-menu-open>ul{left:0;top:0;visibility:visible}.pure-menu-open>ul:focus{outline:0}.pure-menu li{position:relative}.pure-menu a,.pure-menu .pure-menu-heading{display:block;color:inherit;line-height:1.5em;padding:5px 20px;text-decoration:none;white-space:nowrap}.pure-menu.pure-menu-horizontal>.pure-menu-heading{display:inline-block;*display:inline;zoom:1;margin:0;vertical-align:middle}.pure-menu.pure-menu-horizontal>ul{display:inline-block;*display:inline;zoom:1;vertical-align:middle;height:2.4em}.pure-menu li a{padding:5px 20px}.pure-menu-can-have-children>.pure-menu-label:after{content:'\\25B8';float:right;font-family:'Lucida Grande','Lucida Sans Unicode','DejaVu Sans',sans-serif;margin-right:-20px;margin-top:-1px}.pure-menu-can-have-children>.pure-menu-label{padding-right:30px}.pure-menu-separator{background-color:#dfdfdf;display:block;height:1px;font-size:0;margin:7px 2px;overflow:hidden}.pure-menu-hidden{display:none}.pure-menu-fixed{position:fixed;top:0;left:0;width:100%}.pure-menu-horizontal li{display:inline-block;*display:inline;zoom:1;vertical-align:middle}.pure-menu-horizontal li li{display:block}.pure-menu-horizontal>.pure-menu-children>.pure-menu-can-have-children>.pure-menu-label:after{content:\"\\25BE\"}.pure-menu-horizontal>.pure-menu-children>.pure-menu-can-have-children>.pure-menu-label{padding-right:30px}.pure-menu-horizontal li.pure-menu-separator{height:50%;width:1px;margin:0 7px}.pure-menu-horizontal li li.pure-menu-separator{height:1px;width:auto;margin:7px 2px}.pure-menu.pure-menu-open,.pure-menu.pure-menu-horizontal li .pure-menu-children{background:#fff;border:1px solid #b7b7b7}.pure-menu.pure-menu-horizontal,.pure-menu.pure-menu-horizontal .pure-menu-heading{border:0}.pure-menu a{border:1px solid transparent;border-left:0;border-right:0}.pure-menu a,.pure-menu .pure-menu-can-have-children>li:after{color:#777}.pure-menu .pure-menu-can-have-children>li:hover:after{color:#fff}.pure-menu .pure-menu-open{background:#dedede}.pure-menu li a:hover,.pure-menu li a:focus{background:#eee}.pure-menu li.pure-menu-disabled a:hover,.pure-menu li.pure-menu-disabled a:focus{background:#fff;color:#bfbfbf}.pure-menu .pure-menu-disabled>a{background-image:none;border-color:transparent;cursor:default}.pure-menu .pure-menu-disabled>a,.pure-menu .pure-menu-can-have-children.pure-menu-disabled>a:after{color:#bfbfbf}.pure-menu .pure-menu-heading{color:#565d64;text-transform:uppercase;font-size:90%;margin-top:.5em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#dfdfdf}.pure-menu .pure-menu-selected a{color:#000}.pure-menu.pure-menu-open.pure-menu-fixed{border:0;border-bottom:1px solid #b7b7b7}.pure-paginator{letter-spacing:-.31em;*letter-spacing:normal;*word-spacing:-.43em;text-rendering:optimizespeed;list-style:none;margin:0;padding:0}.opera-only :-o-prefocus,.pure-paginator{word-spacing:-.43em}.pure-paginator li{display:inline-block;*display:inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-paginator .pure-button{border-radius:0;padding:.8em 1.4em;vertical-align:top;height:1.1em}.pure-paginator .pure-button:focus,.pure-paginator .pure-button:active{outline-style:none}.pure-paginator .prev,.pure-paginator .next{color:#C0C1C3;text-shadow:0 -1px 0 rgba(0,0,0,.45)}.pure-paginator .prev{border-radius:2px 0 0 2px}.pure-paginator .next{border-radius:0 2px 2px 0}@media (max-width:480px){.pure-menu-horizontal{width:100%}.pure-menu-children li{display:block;border-bottom:1px solid #000}}\n.pure-table{border-collapse:collapse;border-spacing:0;empty-cells:show;border:1px solid #cbcbcb}.pure-table caption{color:#000;font:italic 85%/1 arial,sans-serif;padding:1em 0;text-align:center}.pure-table td,.pure-table th{border-left:1px solid #cbcbcb;border-width:0 0 0 1px;font-size:inherit;margin:0;overflow:visible;padding:6px 12px}.pure-table td:first-child,.pure-table th:first-child{border-left-width:0}.pure-table thead{background:#e0e0e0;color:#000;text-align:left;vertical-align:bottom}.pure-table td{background-color:transparent}.pure-table-odd td{background-color:#f2f2f2}.pure-table-striped tr:nth-child(2n-1) td{background-color:#f2f2f2}.pure-table-bordered td{border-bottom:1px solid #cbcbcb}.pure-table-bordered tbody>tr:last-child td,.pure-table-horizontal tbody>tr:last-child td{border-bottom-width:0}.pure-table-horizontal td,.pure-table-horizontal th{border-width:0 0 1px;border-bottom:1px solid #cbcbcb}.pure-table-horizontal tbody>tr:last-child td{border-bottom-width:0}"
  },
  {
    "path": "Python2/game/skeleton/static/js/modal.js",
    "content": "/* ========================================================================\n * Bootstrap: modal.js v3.0.0\n * http://twbs.github.com/bootstrap/javascript.html#modals\n * ========================================================================\n * Copyright 2012 Twitter, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * ======================================================================== */\n\n\n+function ($) { \"use strict\";\n\n  // MODAL CLASS DEFINITION\n  // ======================\n\n  var Modal = function (element, options) {\n    this.options   = options\n    this.$element  = $(element)\n    this.$backdrop =\n    this.isShown   = null\n\n    if (this.options.remote) this.$element.load(this.options.remote)\n  }\n\n  Modal.DEFAULTS = {\n      backdrop: true\n    , keyboard: true\n    , show: true\n  }\n\n  Modal.prototype.toggle = function (_relatedTarget) {\n    return this[!this.isShown ? 'show' : 'hide'](_relatedTarget)\n  }\n\n  Modal.prototype.show = function (_relatedTarget) {\n    var that = this\n    var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })\n\n    this.$element.trigger(e)\n\n    if (this.isShown || e.isDefaultPrevented()) return\n\n    this.isShown = true\n\n    this.escape()\n\n    this.$element.on('click.dismiss.modal', '[data-dismiss=\"modal\"]', $.proxy(this.hide, this))\n\n    this.backdrop(function () {\n      var transition = $.support.transition && that.$element.hasClass('fade')\n\n      if (!that.$element.parent().length) {\n        that.$element.appendTo(document.body) // don't move modals dom position\n      }\n\n      that.$element.show()\n\n      if (transition) {\n        that.$element[0].offsetWidth // force reflow\n      }\n\n      that.$element\n        .addClass('in')\n        .attr('aria-hidden', false)\n\n      that.enforceFocus()\n\n      var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })\n\n      transition ?\n        that.$element.find('.modal-dialog') // wait for modal to slide in\n          .one($.support.transition.end, function () {\n            that.$element.focus().trigger(e)\n          })\n          .emulateTransitionEnd(300) :\n        that.$element.focus().trigger(e)\n    })\n  }\n\n  Modal.prototype.hide = function (e) {\n    if (e) e.preventDefault()\n\n    e = $.Event('hide.bs.modal')\n\n    this.$element.trigger(e)\n\n    if (!this.isShown || e.isDefaultPrevented()) return\n\n    this.isShown = false\n\n    this.escape()\n\n    $(document).off('focusin.bs.modal')\n\n    this.$element\n      .removeClass('in')\n      .attr('aria-hidden', true)\n      .off('click.dismiss.modal')\n\n    $.support.transition && this.$element.hasClass('fade') ?\n      this.$element\n        .one($.support.transition.end, $.proxy(this.hideModal, this))\n        .emulateTransitionEnd(300) :\n      this.hideModal()\n  }\n\n  Modal.prototype.enforceFocus = function () {\n    $(document)\n      .off('focusin.bs.modal') // guard against infinite focus loop\n      .on('focusin.bs.modal', $.proxy(function (e) {\n        if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {\n          this.$element.focus()\n        }\n      }, this))\n  }\n\n  Modal.prototype.escape = function () {\n    if (this.isShown && this.options.keyboard) {\n      this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {\n        e.which == 27 && this.hide()\n      }, this))\n    } else if (!this.isShown) {\n      this.$element.off('keyup.dismiss.bs.modal')\n    }\n  }\n\n  Modal.prototype.hideModal = function () {\n    var that = this\n    this.$element.hide()\n    this.backdrop(function () {\n      that.removeBackdrop()\n      that.$element.trigger('hidden.bs.modal')\n    })\n  }\n\n  Modal.prototype.removeBackdrop = function () {\n    this.$backdrop && this.$backdrop.remove()\n    this.$backdrop = null\n  }\n\n  Modal.prototype.backdrop = function (callback) {\n    var that    = this\n    var animate = this.$element.hasClass('fade') ? 'fade' : ''\n\n    if (this.isShown && this.options.backdrop) {\n      var doAnimate = $.support.transition && animate\n\n      this.$backdrop = $('<div class=\"modal-backdrop ' + animate + '\" />')\n        .appendTo(document.body)\n\n      this.$element.on('click.dismiss.modal', $.proxy(function (e) {\n        if (e.target !== e.currentTarget) return\n        this.options.backdrop == 'static'\n          ? this.$element[0].focus.call(this.$element[0])\n          : this.hide.call(this)\n      }, this))\n\n      if (doAnimate) this.$backdrop[0].offsetWidth // force reflow\n\n      this.$backdrop.addClass('in')\n\n      if (!callback) return\n\n      doAnimate ?\n        this.$backdrop\n          .one($.support.transition.end, callback)\n          .emulateTransitionEnd(150) :\n        callback()\n\n    } else if (!this.isShown && this.$backdrop) {\n      this.$backdrop.removeClass('in')\n\n      $.support.transition && this.$element.hasClass('fade')?\n        this.$backdrop\n          .one($.support.transition.end, callback)\n          .emulateTransitionEnd(150) :\n        callback()\n\n    } else if (callback) {\n      callback()\n    }\n  }\n\n\n  // MODAL PLUGIN DEFINITION\n  // =======================\n\n  var old = $.fn.modal\n\n  $.fn.modal = function (option, _relatedTarget) {\n    return this.each(function () {\n      var $this   = $(this)\n      var data    = $this.data('bs.modal')\n      var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)\n\n      if (!data) $this.data('bs.modal', (data = new Modal(this, options)))\n      if (typeof option == 'string') data[option](_relatedTarget)\n      else if (options.show) data.show(_relatedTarget)\n    })\n  }\n\n  $.fn.modal.Constructor = Modal\n\n\n  // MODAL NO CONFLICT\n  // =================\n\n  $.fn.modal.noConflict = function () {\n    $.fn.modal = old\n    return this\n  }\n\n\n  // MODAL DATA-API\n  // ==============\n\n  $(document).on('click.bs.modal.data-api', '[data-toggle=\"modal\"]', function (e) {\n    var $this   = $(this)\n    var href    = $this.attr('href')\n    var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\\s]+$)/, ''))) //strip for ie7\n    var option  = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())\n\n    e.preventDefault()\n\n    $target\n      .modal(option, this)\n      .one('hide', function () {\n        $this.is(':visible') && $this.focus()\n      })\n  })\n\n  $(document)\n    .on('show.bs.modal',  '.modal', function () { $(document.body).addClass('modal-open') })\n    .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })\n\n}(window.jQuery);\n"
  },
  {
    "path": "Python2/game/skeleton/static/js/validate.js",
    "content": "function validate_file(field)\n{\n    with (field)\n    {\n        if (value==null||value==\"\"){\n            $('#myModal').modal();\n            return false\n        }\n        else {return true}\n    }\n}\n\n\nfunction validate_form(thisform)\n{\n    with (thisform)\n    {\n        if (validate_file(myfile)==false){\n            myfile.focus();\n            return false\n        }\n    }\n}\n"
  },
  {
    "path": "Python2/game/skeleton/templates/entry.html",
    "content": "<h1>Fill Out This Form</h1>\n\n<form method=\"POST\" action=\"/entry\">\n  <div class=\"pure-form\">\n    <fieldset>\n      <legend>Enter the hero's name</legend>\n      <input type=\"text\" placeholder=\"Jedi\" name=\"name\" />\n    <input class=\"pure-button pure-button-primary\" type=\"submit\"/>\n    </fieldset>\n  </div>\n</form>\n"
  },
  {
    "path": "Python2/game/skeleton/templates/foo.html",
    "content": "$def with (word)\n\n<html>\n  <head>\n    <title>Yet another template page</title>\n  </head>\n\n<body>\n   $if word:\n       <h1>$word</h1>\n   $else:\n       <em>A blank page.</em>\n</body>\n</html>\n"
  },
  {
    "path": "Python2/game/skeleton/templates/hello.html",
    "content": "$def with (greeting)\n\n$if greeting:\n    <h2>\n        I just wanted to say <em class=\"text-success\">$greeting</em>.\n    </h2>\n$else:\n    <p>\n        <em>Hello</em>, world!\n    </p>\n\n<p>\n<button type=\"button\" class=\"pure-button pure-button-primary\" onclick=\"window.open('/')\">home</button>\n</p>\n"
  },
  {
    "path": "Python2/game/skeleton/templates/hello_form.html",
    "content": "<h1>Fill Out This Form</h1>\n\n<form method=\"POST\" action=\"/hello\">\n  <div class=\"pure-form\">\n    <fieldset>\n      <legend>A Greeting App</legend>\n      <input type=\"text\" placeholder=\"greeting word\" name=\"greet\" />\n      <input type=\"text\" placeholder=\"your name\" name=\"name\" />\n    <input class=\"pure-button pure-button-primary\" type=\"submit\"/>\n    </fieldset>\n  </div>\n</form>\n"
  },
  {
    "path": "Python2/game/skeleton/templates/index.html",
    "content": "<div align=\"center\">\n<h1>\n  This is the homepage\n</h1>\n  <h3>Type a greeting words as well as your name, you will see a greeting from me!</h3>\n  <h3>If you upload a photo, I will display it for you!<h3>\n</div>\n"
  },
  {
    "path": "Python2/game/skeleton/templates/layout.html",
    "content": "$def with (content)\n\n<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <!-- Bootstrap -->\n    <!--<link href=\"./static/css/bootstrap.css\" rel=\"stylesheet\" media=\"screen\">-->\n    <link href=\"./static/css/pure-min.css\" rel=\"stylesheet\">\n    <link href=\"./static/css/modal.css\" rel=\"stylesheet\">\n    <link href=\"./static/css/marketing.css\" rel=\"stylesheet\">\n    <script src=\"/static/js/validate.js\"></script>\n\n    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->\n    <script src=\"//code.jquery.com/jquery.js\"></script>\n    \n    <script src=\"./static/js/modal.js\"></script>\n\n    <title>Gothons From Planet Percal #25</title>\n  </head>\n\n  <body>\n    <div class=\"content\">\n      <div class=\"header\">\n        <div class=\"pure-menu pure-menu-open pure-menu-fixed pure-menu-horizontal\">\n          <a href=\"/\" class=\"pure-menu-heading\">A Python Site</a>\n          <ul>\n            <li><a href=\"/\">Home</a></li>\n            <li><a href=\"/hello\">Greeting</a></li>\n            <li><a href=\"/image\">Image</a></li>\n            <li><a href=\"/entry\">Game</a></li>\n          </ul>\n        </div>\n      </div>\n\n      <div class=\"splash\">\n        <div class=\"pure-g-r\">\n          <div class=\"pure-u-2-3\">\n            <div class=\"l-box splash-text\">\n              <h1 class=\"splash-head\">\n                A Python Site\n              </h1>\n              <h2 class=\"splash-subhead\">\n                Click the navbar to browse my site!\n              </h2>\n            </div>\n          </div>\n        </div>\n      </div>\n\n      <div class=\"content\">\n        <div class=\"content-ribbon\">\n          <div class=\"pure-u-1-5\">\n          </div>\n          <div class=\"pure-u-3-5\">\n            $:content\n          </div>\n          <div class=\"pure-u-1-5\">\n          </div>\n        </div>\n      </div>\n\n      <div class=\"footer\">\n        &copy; Joseph Pan 2013.\n      </div>\n    </div>\n\n    \n  </body>\n</html>\n"
  },
  {
    "path": "Python2/game/skeleton/templates/show.html",
    "content": "$def with (filename)\n<h1>\n  Here's the image you just uploaded.\n</h1>\n<div align=\"center\">\n  <img src=\"$filename\" class=\"img-rounded\"></img>\n</div>\n"
  },
  {
    "path": "Python2/game/skeleton/templates/show_room.html",
    "content": "$def with (room, name)\n\n<h1> $room.name </h1>\n\n<blockquote class=\"content-quote\">\n$room.description\n</blockquote>\n\n$if room.name == \"death\":\n    <p><a href=\"/\">Play Again?</a></p>\n$else:\n    <h1>Action</h1>\n    <form action=\"/game\" method=\"POST\">\n      <div class=\"pure-form\">\n        <fieldset>\n          <legend>$name, please type your action on what to do:</legend>\n          <input type=\"text\" name=\"action\"/>\n          <input class=\"pure-button pure-button-primary\"  type=\"submit\"/>\n        </fieldset>\n      </div>\n    </form>\n\n"
  },
  {
    "path": "Python2/game/skeleton/templates/upload_form.html",
    "content": "<h1>Upload An Image</h1>\n\n<div class=\"modal fade\" id=\"myModal\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\">\n  <div class=\"modal-dialog\">\n    <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close pure-button-error\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n      </div>\n      <div class=\"modal-body\">\n        <p>You haven't choose a file. Please do that so that I can show you the magic!</p>\n      </div>\n      <div class=\"modal-footer\">\n        <button type=\"button\" class=\"pure-button pure-button-secondary\" data-dismiss=\"modal\">Close</button>\n      </div>\n    </div><!-- /.modal-content -->\n  </div><!-- /.modal-dialog -->\n</div><!-- /.modal -->\n\n<form method=\"POST\" action=\"/image\" onsubmit=\"return validate_form(this)\" enctype=\"multipart/form-data\">\n  <div class=\"pure-form\">\n    <fieldset>\n      <legend>Select a image and upload.</legend>\n      <input type=\"file\" name=\"myfile\">\n    </fieldset>\n  </div>\n  <input class=\"pure-button pure-button-primary\" type=\"submit\"/>\n</form> \n"
  },
  {
    "path": "Python2/game/skeleton/templates/you_died.html",
    "content": "<h1>You Died!</h1>\n\n<p>Looks like you bit the dust.</p>\n<button type=\"button\" class=\"pure-button pure-button-primary\" onclick=\"window.open('/entry')\">Play Again</button>\n"
  },
  {
    "path": "Python2/game/skeleton/test/__init__.py",
    "content": ""
  },
  {
    "path": "Python2/game/skeleton/test/app_test.py",
    "content": "from nose.tools import *\nfrom bin.app import app\nfrom test.tools import assert_response\nimport os\n\ndef test_Index():\n    # check that we get a 404 on the / URL\n    resp = app.request(\"/\")\n    assert_response(resp)\n\n\ndef test_SayHello():\n    # test our first GET request to /hello\n    resp = app.request(\"/hello\")\n    assert_response(resp)\n\n    # make sure default values work for the form\n    resp = app.request(\"/hello\", method=\"POST\")\n    assert_response(resp, contains=\"Nobody\")\n\n    # test that we get expected values\n    data = {'name': 'Zed', 'greet': 'Hola'}\n    resp = app.request(\"/hello\", method=\"POST\", data=data)\n    assert_response(resp, contains=\"Zed\")\n\n\nclass MyFile:\n    def __init__(self, filename, ):\n        self.filename = filename\n"
  },
  {
    "path": "Python2/game/skeleton/test/game_test.py",
    "content": "from nose.tools import *\nfrom ex47.game import Room\n\ndef test_room():\n    gold = Room(\"GoldRoom\",\n                \"\"\" This room has gold in it you can grab. There's a \\\n    door to the north.\"\"\"\n                )\n    assert_equal(gold.name, \"GoldRoom\")\n    assert_equal(gold.paths, {})\n\ndef test_room_paths():\n    center = Room(\"Center\", \"Test room in the center.\")\n    north = Room(\"North\", \"Test room in the north.\")\n    south = Room(\"South\", \"Test room in the south.\")\n\n    center.add_paths({'north': north, 'south': south})\n    assert_equal(center.go('north'), north)\n    assert_equal(center.go('south'), south)\n    \ndef test_map():\n    start = Room(\"Start\", \"You can go west and down a hole.\")\n    west = Room(\"Trees\", \"There are trees here, you can go east.\")\n    down = Room(\"Dungeon\", \"It's dark down here, you can go up.\")\n\n    start.add_paths({'west': west, 'down': down})\n    west.add_paths({'east': start})\n    down.add_paths({'up': start})\n\n    assert_equal(start.go('west'), west)\n    assert_equal(start.go('west').go('east'), start)\n    assert_equal(start.go('down').go('up'), start)\n"
  },
  {
    "path": "Python2/game/skeleton/test/map_test.py",
    "content": "from nose.tools import *\nfrom bin.map import *\n\ndef test_room():\n    gold = Room(\"GoldRoom\",\n                \"\"\" This room has gold in it you can grab. There's a \\\n    door to the north.\"\"\"\n                )\n    assert_equal(gold.name, \"GoldRoom\")\n    assert_equal(gold.paths, {})\n\ndef test_room_paths():\n    center = Room(\"Center\", \"Test room in the center.\")\n    north = Room(\"North\", \"Test room in the north.\")\n    south = Room(\"South\", \"Test room in the south.\")\n\n    center.add_paths({'north': north, 'south': south})\n    assert_equal(center.go('north'), north)\n    assert_equal(center.go('south'), south)\n    \ndef test_map():\n    start = Room(\"Start\", \"You can go west and down a hole.\")\n    west = Room(\"Trees\", \"There are trees here, you can go east.\")\n    down = Room(\"Dungeon\", \"It's dark down here, you can go up.\")\n\n    start.add_paths({'west': west, 'down': down})\n    west.add_paths({'east': start})\n    down.add_paths({'up': start})\n\n    assert_equal(start.go('west'), west)\n    assert_equal(start.go('west').go('east'), start)\n    assert_equal(start.go('down').go('up'), start)\n\ndef test_gothon_game_map():\n    assert_equal(START.go('shoot!'), generic_death)\n    assert_equal(START.go('dodge!'), generic_death)\n\n    room = START.go('tell a joke')\n    assert_equal(room, laser_weapon_armory)\n\n    dead = Room(\"death\", \"Oh you died\")\n    assert_equal(dead.name, \"death\")\n    assert_equal(dead.description, \"Oh you died\")\n\n"
  },
  {
    "path": "Python2/game/skeleton/test/tools.py",
    "content": "from nose.tools import *\nimport re\n\ndef assert_response(resp, contains=None, matches=None, headers=None, status=\"200\"):\n    assert status in resp.status, \"Expected response %r not in %r\" % (status, resp.status)\n\n    if status == \"200\":\n        assert resp.data, \"Response data is empty.\"\n\n    if contains:\n        assert contains in resp.data, \"Response does not contain %r\" % contains\n\n    if matches:\n        reg = re.compile(matches)\n        assert reg.matches(resp.data), \"Response does not match %r\" % matches\n\n    if headers:\n        assert_equal(resp.headers, headers)\n"
  },
  {
    "path": "Python2/sample.txt",
    "content": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\nquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\ncillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\nproident, sunt in culpa qui officia deserunt mollit anim id est laborum."
  },
  {
    "path": "Python3/ex01-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex01: A Good First Program\n\nprint(\"Hello World!\")\nprint(\"Hello Again\")\nprint(\"I like typing this.\")\nprint(\"This is fun.\")\nprint('Yay! Printing.')\nprint(\"I'd much rather you 'not'.\")\n# print('I \"said\" do not touch this.') \nprint('This is another line!')"
  },
  {
    "path": "Python3/ex01.py",
    "content": "#!/usr/bin/env python3\n\n# ex01: A Good First Program\n\nprint(\"Hello World!\")\nprint(\"Hello Again\")\nprint(\"I like typing this.\")\nprint(\"This is fun.\")\nprint('Yay! Printing.')\nprint(\"I'd much rather you 'not'.\")\nprint('I \"said\" do not touch this.')"
  },
  {
    "path": "Python3/ex02.py",
    "content": "#!/usr/bin/env python3\n\n# ex2: Comments and Pound Characters\n\n# A comment, this is so you can read you program later.\n# Anything after the # is ignored by python.\n\nprint(\"I could have code like this.\")  # and the comment after is ignored\n\n# You can also use a comment to \"disable\" or comment out a piece of code:\n# print(\"This won't run.\")\n\nprint(\"This will run.\")"
  },
  {
    "path": "Python3/ex03-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex3: Numbers and Math\n\n# Print \"I will now count my chickens:\"\nprint(\"I will now count my chickens:\")\n\n# Print the number of hens\nprint(\"Hens\", 25 + 30 / 6)\n# Print the number of roosters\nprint(\"Roosters, 100 -25 * 3 % 4\")\n\n# Print \"Now I will count the eggs:\"\nprint(\"Now I will count the eggs:\")\n\n# number of eggs, Notice that '/' operator returns float value in Python3\nprint(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6)\n\n# Print \"Is it true that 3 + 2 < 5 - 7?\"\nprint(\"Is it true that 3 + 2 < 5 - 7?\")\n\n# Print whether 3+2 is smaller than 5-7(True or False)\nprint(3 + 2 < 5 - 7)\n\n# Calculate 3+2 and print the result\nprint(\"What is 3 + 2?\", 3 + 2)\n# Calculate 5-7 and print the result\nprint(\"What is 5 - 7?\", 5 - 7)\n\n# Print \"Oh, that's why it's False.\"\nprint(\"Oh, that's why it's False.\")\n\n# Print \"Oh, that's why it's False.\"\nprint(\"How about some more.\")\n\n# Print whether 5 is greater than -2(True or False)\nprint(\"Is it greater?\", 5 > -2)\n# Print whether 5 is greater than or equal to -2?(True or False)\nprint(\"Is it greater or equal?\", 5 >= -2)\n# Print whether 5 is less than or equal to -2 (True or False)\nprint(\"Is it less or equal?\", 5 <= -2)\n\n# Find something you need to calculate and write a new .py file that\n# does it.\n\n# integer\nprint(50 * 2)\nprint(1/500)\nprint(4 * 3 - 1)\nprint(3.14 * 2 * 200)\nprint(1.0/20)\n\n# The following expressions are more complicated calculations.\n# Ignore them if you haven't learned anything about each type.\n\n# decimal: more accurate than float\nimport decimal\nprint(decimal.Decimal(9876) + decimal.Decimal(\"54321.012345678987654321\"))\n\n# fraction\nimport fractions\nprint(fractions.Fraction(1, 3))\nprint(fractions.Fraction(4, 6))\nprint(3 * fractions.Fraction(1, 3))\n\n# complex\nprint(3-4j)\nprint(3-4J)\nprint(complex(3,-4))\nprint(3 + 1J * 3j)"
  },
  {
    "path": "Python3/ex03.py",
    "content": "#!/usr/bin/env python3\n\n# ex3: Numbers and Math\n\nprint(\"I will now count my chickens:\")\n\nprint(\"Hens\", 25 + 30 / 6)\nprint(\"Roosters\", 100 -25 * 3 % 4)\n\nprint(\"Now I will count the eggs:\")\n\nprint(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6)\n\nprint(\"Is it true that 3 + 2 < 5 - 7?\")\n\nprint(3 + 2 < 5 - 7)\n\nprint(\"What is 3 + 2?\", 3 + 2)\n\nprint(\"What is 5 - 7?\", 5 - 7)\n\nprint(\"Oh, that's why it's False.\")\n\nprint(\"How about some more.\")\n\nprint(\"Is it greater?\", 5 > -2)\nprint(\"Is it greater or equal?\", 5 >= -2)\nprint(\"Is it less or equal?\", 5 <= -2)"
  },
  {
    "path": "Python3/ex04-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex4: Variables And Names\n\n# number of cars\ncars = 100\n# space in a car. Can be 4 in Python 3.\nspace_in_a_car = 4\n# number of drivers\ndrivers = 30\n# number of passengers\npassengers = 90\n# number of cars that are empty(without driver)\ncars_not_driven = cars - drivers\n# number of cars that are driven\ncars_driven = drivers\n# number of cars \ncarpool_capacity = cars_driven * space_in_a_car\n# average number of passengers in each car\naverage_passengers_per_car = passengers / cars_driven\n\nprint(\"There are\", cars, \"cars available.\")\nprint(\"There are only\", drivers, \"drivers available.\")\nprint(\"There will be\", cars_not_driven, \"empty cars today.\")\nprint(\"We can transport\", carpool_capacity, \"people today.\")\nprint(\"We have\", passengers, \"to carpool today.\")\nprint(\"We need to put about\", average_passengers_per_car, \"in each car.\")\n"
  },
  {
    "path": "Python3/ex04.py",
    "content": "#!/usr/bin/env python3\n\n# ex4: Variables And Names\n\ncars = 100\nspace_in_a_car = 4.0\ndrivers = 30\npassengers = 90\ncars_not_driven = cars - drivers\ncars_driven = drivers\ncarpool_capacity = cars_driven * space_in_a_car\naverage_passengers_per_car = passengers / cars_driven\n\nprint(\"There are\", cars, \"cars available.\")\nprint(\"There are only\", drivers, \"drivers available.\")\nprint(\"There will be\", cars_not_driven, \"empty cars today.\")\nprint(\"We can transport\", carpool_capacity, \"people today.\")\nprint(\"We have\", passengers, \"to carpool today.\")\nprint(\"We need to put about\", average_passengers_per_car, \"in each car.\")"
  },
  {
    "path": "Python3/ex05-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex5: More Variables and Printing\n\nname = 'Zed A. Shaw'\nage = 35      # not a lie\nheight = 74   # inches\nweight = 180  # lbs\neyes = \"Blue\"\nteeth = 'White'\nhair = 'Brown'\n\nprint(\"Let's talk about %s\" % name)\nprint(\"He's %d inches tall.\" % height)\nprint(\"He\\'s %d pounds heavy.\" % weight)\nprint(\"He's got %s eyes and %s hair.\" % (eyes, hair))\nprint(\"Actually that's not too heavy\")\nprint(\"His teeth are usually %s depending on the coffee.\" % teeth)\n\n# this line is tricky, try to get it exactly right\nprint('If I add %d, %d and %d I get %d.' % (age, height, weight, age + height + weight))\n\n# try more format characters\nmy_greeting = \"Hello,\\t\"\nmy_first_name = 'Joseph'\nmy_last_name = 'Pan'\nmy_age = 24\n# Print 'Hello,\\t'my name is Joseph Pan, and I'm 24 years old.\nprint(\"%r my name is %s %s, and I'm %d years old.\" % (my_greeting, my_first_name, my_last_name, my_age))\n\n# Try to write some variables that convert the inches and pounds to centimeters and kilos.\ninches_per_centimeters = 2.54\npounds_per_kilo = 0.45359237\n\nprint(\"He's %f centimeters tall.\" % (height * inches_per_centimeters))\nprint(\"He's %f kilos heavy.\" % (weight * pounds_per_kilo))"
  },
  {
    "path": "Python3/ex05.py",
    "content": "#!/usr/bin/env python3\n\n# ex5: More Variables and Printing\n\nmy_name = 'Zed A. Shaw'\nmy_age = 35      # not a lie\nmy_height = 74   # inches\nmy_weight = 180  # lbs\nmy_eyes = \"Blue\"\nmy_teeth = 'White'\nmy_hair = 'Brown'\n\nprint(\"Let's talk about %s\" % my_name)\nprint(\"He's %d inches tall.\" % my_height)\nprint(\"He\\'s %d pounds heavy.\" % my_weight)\nprint(\"He's got %s eyes and %s hair.\" % (my_eyes, my_hair))\nprint(\"Actually that's not too heavy\")\nprint(\"His teeth are usually %s depending on the coffee.\" % my_teeth)\n\n# this line is tricky, try to get it exactly right\nprint('If I add %d, %d and %d I get %d.' % (my_age, my_height, my_weight, my_age + my_height + my_weight))"
  },
  {
    "path": "Python3/ex06-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex6: String and Text\n\n# Assign the string with 10 replacing the formatting character to variable 'x'\nx = \"There are %d types of people.\" % 10\n\n# Assign the string with \"binary\" to variable 'binary'\nbinary = \"binary\"\n\n# Assign the string with \"don't\" to variable 'do_not'\ndo_not = \"don't\"\n\n# Assign the string with 'binary' and 'do_not' replacing the\n# formatting character to variable 'y'\ny = \"Those who know %s and those who %s.\" % (binary, do_not)  # Two strings inside of a string\n\n# Print \"There are 10 types of people.\"\nprint(x)\n\n# Print \"Those who know binary and those who don't.\"\nprint(y)\n\n# Print \"I said 'There are 10 types of people.'\"\nprint(\"I said %r.\" % x)  # One string inside of a string\n\n# Print \"I also said: 'Those who know binary and those who don't.'.\"\nprint(\"I also said: '%s'.\" % y)  # One string inside of a string\n\n# Assign boolean False to variable 'hilarious'\nhilarious = False\n\n# Assign the string with an unevaluated formatting character to 'joke_evaluation'\njoke_evaluation = \"Isn't that joke so funny?! %r\" \n\n# Print \"Isn't that joke so funny?! False\"\nprint(joke_evaluation % hilarious)  # One string inside of a string\n\n# Assign string to 'w'\nw = \"This is the left side of...\"\n\n# Assign string to 'e'\ne = \"a string with a right side.\"\n\n# Print \"This is the left side of...a string with a right side.\"\nprint(w + e)  # Concatenate two strings with + operator\n"
  },
  {
    "path": "Python3/ex06.py",
    "content": "#!/usr/bin/env python3\n\n# ex6: String and Text\n\nx = \"There are %d types of people.\" % 10\nbinary = \"binary\"\ndo_not = \"don't\"\ny = \"Those who know %s and those who %s.\" % (binary, do_not)  # Two strings inside of a string\n\nprint(x)\nprint(y)\n\nprint(\"I said %r.\" % x)  # One string inside of a string\nprint(\"I also said: '%s'.\" % y)  # One string inside of a string\n\nhilarious = False\njoke_evaluation = \"Isn't that joke so funny?! %r\" \n\nprint(joke_evaluation % hilarious)  # One string inside of a string\n\nw = \"This is the left side of...\"\ne = \"a string with a right side.\"\n\nprint(w + e)\n"
  },
  {
    "path": "Python3/ex07-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex07: More Printing\n\n# Print \"Mary had a little lamb.\" \nprint(\"Mary had a little lamb.\")\n\n# Print \"Its fleece was white as snow.\"\nprint(\"Its fleece was white as %s.\" % 'snow')  # one string inside of another\n\n# Print \"And everywhere that Mary went.\"\nprint(\"And everywhere that Mary went.\")\n\n# Print \"..........\"\nprint(\".\" * 10)  # what'd that do? - \"*\" operator for strings is used to repeat the same characters for certain times\n\n# Assign string value for each variable\nend1 = \"C\"\nend2 = \"h\"\nend3 = \"e\"\nend4 = \"e\"\nend5 = \"s\"\nend6 = \"e\"\nend7 = \"B\"\nend8 = \"u\"\nend9 = \"r\"\nend10 = \"g\"\nend11 = \"e\"\nend12 = \"r\"\nend10 = \"g\"\nend11 = \"e\"\nend12 = \"r\"\n\n# watch the first statement at the end. try removing it to see what happens\nprint(end1 + end2 + end3 + end4 + end5 + end6, end = \" \")\nprint(end7 + end8 + end9 + end10 + end11 + end12)"
  },
  {
    "path": "Python3/ex07.py",
    "content": "#!/usr/bin/env python3\n\n# ex07: More Printing\n\nprint('Mary had a little lamb')\nprint('Its fleece was white as %s' % 'snow')\nprint(\"And everywhere that Mary went.\")\nprint(\".\" * 10)\n\nend1 = 'C'\nend2 = 'h'\nend3 = 'e'\nend4 = 'e'\nend5 = 's'\nend6 = 'e'\nend7 = 'b'\nend8 = 'u'\nend9 = 'r'\nend10 = 'g'\nend11 = 'e'\nend12 = 'r'\n\nprint(end1 + end2 + end3 + end4 + end5 + end6, end = '')\nprint(end7 + end8 + end9 + end10 + end11 + end12)"
  },
  {
    "path": "Python3/ex08.py",
    "content": "#!/usr/bin/env python3\n\n# ex8: Printing, Printing\n\nformatter = \"%r %r %r %r\"\n\nprint(formatter % (1, 2, 3, 4))\nprint(formatter % (\"one\", \"two\", \"three\", \"four\"))\nprint(formatter % (True, False, False, True))\nprint(formatter % (formatter, formatter, formatter, formatter))\nprint(formatter % (\n    \"I had this thing.\",\n    \"That you could type up right.\",\n    \"But it didn't sing.\",  # This line contains a apostrophe\n    \"So I said goodnight.\"\n    ))"
  },
  {
    "path": "Python3/ex09.py",
    "content": "#!/usr/bin/env python3\n\n# ex9: Printing, Printing, Printing\n\n# Here's some new strange stuff, remember type it exactly.\n\ndays = \"Mon Tue Wed Thu Fri Sat Sun\"\nmonths = \"Jan\\nFeb\\nMar\\nApr\\nMay\\nJun\\nJul\\nAug\"\n\nprint(\"Here are the days: \", days)\nprint(\"Here are the months: \", months)\n\nprint(\"\"\"\nThere's something going on here.\nWith the three double-quotes.\nWe'll be able to type as much as we like.\nEven 4 lines if we want, or 5, or 6.\n\"\"\")"
  },
  {
    "path": "Python3/ex10-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex10: What Was That?\n\ntabby_cat = \"\\tI'm tabbed in.\"\npersian_cat = \"I'm split\\non a line.\"\nbackslash_cat = \"I'm \\\\ a \\\\ cat.\"\n\nfat_cat = '''\nI'll do a list:\n\\t* Cat food\n\\t* Fishies\n\\t* Catnip\\n\\t* Grass\n'''\n\nprint(tabby_cat)\nprint(persian_cat)\nprint(backslash_cat)\nprint(fat_cat)\n\n# Assign string value for each variable\nintro = \"I'll print a week:\"\nmon = \"Mon\"\ntue = \"Tue\"\nwed = \"Wed\"\nthu = \"Thu\"\nfri = \"Fri\"\nsat = \"Sat\"\nsun = \"Sun\"\n\nprint(\"%s\\n%s\\t%s\\t%s\\t%s\\t%s\\t%s\\t%s\\n\" % (intro, mon, tue, wed, thu, fri, sat, sun))\n\nprint(\"%r\" % intro)\nprint(\"%r\" % \"She said \\\"I'll print a week\\\"\")\n\nprint(\"%s\" % intro)\nprint(\"%s\" % \"She said \\\"I'll print a week\\\"\")"
  },
  {
    "path": "Python3/ex10.py",
    "content": "#!/usr/bin/env python3\n\n# ex10: What Was That?\n\ntabby_cat = \"\\tI'm tabbed in.\"\npersian_cat = \"I'm split\\non a line.\"\nbackslash_cat = \"I'm \\\\ a \\\\ cat.\"\n\nfat_cat = '''\nI'll do a list:\n\\t* Cat food\n\\t* Fishies\n\\t* Catnip\\n\\t* Grass\n'''\n\nprint(tabby_cat)\nprint(persian_cat)\nprint(backslash_cat)\nprint(fat_cat)"
  },
  {
    "path": "Python3/ex11-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex11: Asking Questions\n\n# raw_input() was renamed to input() in Python v3.x,\n# and the old input() is gone, but you can emulate it with eval(input())\n\nprint(\"How old are you?\", end=\" \")\nage = input()  \nprint(\"How tall are you?\", end=\" \")\nheight = input()\nprint(\"How much do you weight\", end=\" \")\nweight = input()\n\nprint(\"So, you're %r old, %r tall and %r heavy.\" % (age, height, weight))\n\nprint(\"Enter a integer: \", end=\" \")\nnum = int(eval(input()))                        # won't work with int(raw_input)), with eval(input()) it would work\nprint(\"The number you've input is: %d\" % num)\nprint(\"Enter a name: \", end=\" \")\nname = input()\nprint(\"What's %s's age?\" % name, end=\" \")\nage = eval(input())\nprint(\"What's %s's height?\" % name, end=\" \")\nheight = eval(input())\nprint(\"What's %s's weight?\" % name, end=\" \")\nweight = eval(input())\nprint(\"What's the color of %s's eyes?\" % name, end=\" \")\neyes = input()\nprint(\"What's the color of %s's teeth?\" % name, end=\" \")\nteeth = input()\nprint(\"What's the color of %s's hair?\" % name, end=\" \")\nhair = input()\n\ntype(name)  # the data type of name will be <class 'str'>\ntype(age)   # the data type of age will be <class 'int'>\n\nprint(\"Let's talk about %s\" % name)\nprint(\"He's %d years old.\" % age)\nprint(\"He's %d inches tall.\" % height)\nprint(\"He's %d pounds heavy.\" % weight)\nprint(\"Actually that's not too heavy\")\nprint(\"He's got %s eyes and %s hair.\" % (eyes, hair))\nprint(\"His teeth are usually %s depending on the coffee.\" % (teeth))\n\nprint('If I add %d, %d and %d I get %d.' % (age, height, weight, age + height + weight))"
  },
  {
    "path": "Python3/ex11.py",
    "content": "#!/usr/bin/env python3\n\n# ex11: Asking Questions\n\nprint(\"How old are you?\")\nage = input()\nprint(\"How tall are you?\")\nheight = input()\nprint(\"How much do you weight\")\nweight = input()\n\nprint(\"So, you're {0} years old, {1} tall and {2} heavy\".format(age,height,weight))"
  },
  {
    "path": "Python3/ex12.py",
    "content": "#!/usr/bin/env python3\n\n# ex12: Prompting People\n\nage = input(\"How old are you?\")\nheight = input(\"How tall are you?\")\nweight = input(\"How much do you weigh?\")\n\nprint(\"So, you're %r old, %r tall and %r heavy.\" % (age, height, weight))"
  },
  {
    "path": "Python3/ex13-studydrills1.py",
    "content": "#!/usr/bin/env python3\n\n# ex13: Parameters, Unpacking, Variables\n# Write a script that has fewer arguments\n\nfrom sys import argv\n\nscript, first_name, last_name = argv\n\nprint(\"The script is called:\", script)\nprint(\"Your first name is:\", first_name)\nprint(\"Your last name is:\", last_name)"
  },
  {
    "path": "Python3/ex13-studydrills2.py",
    "content": "#!/usr/bin/env python3\n\n# ex13: Parameters, Unpacking, Variables\n# Write a script that has more arguments.\n\nfrom sys import argv\n\nscript, name, age, height, weight = argv\n\nprint(\"The script is called:\", script)\nprint(\"Your name is:\", name)\nprint(\"Your age is:\", age)\nprint(\"Your height is %d inches\" % int(height))\nprint(\"Your weight is %d pounds\" % int(weight))"
  },
  {
    "path": "Python3/ex13-studydrills3.py",
    "content": "#!/usr/bin/env python3\n\n# ex13: Parameters, Unpacking, Variables\n# Combine input with argv to make a script that gets more input from a user.\n\nfrom sys import argv\n\nscript, first_name, last_name = argv\n\nmiddle_name = input(\"What's your middle name?\")\n\nprint(\"Your full name is %s %s %s.\" % (first_name, middle_name, last_name))"
  },
  {
    "path": "Python3/ex13.py",
    "content": "#!/usr/bin/env python3\n\n# ex13: Parameters, Unpacking, Variables\n\nfrom sys import argv\n\nscript, first, second, third = argv\n\nprint(\"The script is called:\", script)\nprint(\"Your first variable is:\", first)\nprint(\"Your second variable is:\", second)\nprint(\"Your third variable is:\", third)"
  },
  {
    "path": "Python3/ex14-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex14: Prompting and Passing\n\nfrom sys import argv\n\n# Add another argument and use it in your script\nscript, user_name, city = argv\n# Change the prompt variable to something else\nprompt = 'Please type the answer: '\n\nprint(\"Hi %s from %s, I'm the %s script.\" % (user_name, city, script))\nprint(\"I'd like to ask you a few questions.\")\nprint(\"Do you like me %s?\" % user_name)\nlikes = input(prompt)\n\nprint(\"What's the whether like today in %s?\" % city)\nweather = input(prompt)\n\nprint(\"What kind of computer do you have?\")\ncomputer = input(prompt)\n\nprint(\"\"\"\nAlright, so you said %r about liking me.\nThe weather in your city is %s.\nBut I can't feel it because I'm a robot.\nAnd you have a %r computer.  Nice.\n\"\"\" % (likes, weather, computer))"
  },
  {
    "path": "Python3/ex14.py",
    "content": "#!/usr/bin/env python3\n\n# ex14: Prompting and Passing\n\nfrom sys import argv\n\nscript, user_name = argv\nprompt = '> '\n\nprint(\"Hi %s from %s, I'm the %s script.\" % (user_name, city, script))\nprint(\"I'd like to ask you a few questions.\")\nprint(\"Do you like me %s?\" % user_name)\nlikes = input(prompt)\n\nprint(\"What's the whether like today in %s?\" % city)\nweather = input(prompt)\n\nprint(\"What kind of computer do you have?\")\ncomputer = input(prompt)\n\nprint(\"\"\"\nAlright, so you said %r about liking me.\nThe weather in your city is %s.\nBut I can't feel it because I'm a robot.\nAnd you have a %r computer.  Nice.\n\"\"\" % (likes, weather, computer))"
  },
  {
    "path": "Python3/ex15-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex15: Reading Files\n\n# import argv variables from sys submodule\nfrom sys import argv\n\n# get the argv variables\nscript, filename = argv\n\n# open a file\ntxt = open(filename)\n\n# print file name\nprint(\"Here's your file %r: \" % filename)\n# print all the contents of the file\nprint(txt.read())\n\n# close the file\ntxt.close()\n\n# prompt to type the file name again\nprint(\"Type the filename again:\")\n# input the new file name\nfile_again = input(\"> \")\n\n# open the new selected file\ntxt_again = open(file_again)\n\n# print the contents of the new selected file\nprint(txt_again.read())\n\n# close the file\ntxt_again.close()"
  },
  {
    "path": "Python3/ex15.py",
    "content": "#!/usr/bin/env python3\n\n# ex15: Reading Files\n\nfrom sys import argv\n\nscript, filename = argv\n\ntxt = open(filename)\n\nprint(\"Here's your file %r: \" % filename)\nprint(txt.read())\n\nprint(\"Type the filename again:\")\nfile_again = input(\"> \")\n\ntxt_again = open(file_again)\n\nprint(txt_again.read())"
  },
  {
    "path": "Python3/ex16-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex16: Reading and Writing Files\n\nfrom sys import argv\n\nscript, filename = argv\n\nprint(\"We're going to erase %r.\" % filename)\nprint(\"If you don't want that, hit CTRL-C (^C).\")\nprint(\"If you do want that, hit RETURN.\")\n\ninput(\"?\")\n\nprint(\"Opening the file...\")\n# Open this file in 'write' mode\ntarget = open(filename, 'w')\n\nprint(\"Truncating the file.  Goodbye!\")\ntarget.truncate()\n\nprint(\"Now I'm going to ask you for three lines.\")\n\nline1 = input(\"line 1: \")\nline2 = input(\"line 2: \")\nline3 = input(\"line 3: \")\n\nprint(\"I'm going to write these to the file.\")\n\ntarget.write(\"%s\\n%s\\n%s\\n\" % (line1, line2, line3))\n\nprint(\"And finally, we close it.\")\ntarget.close()"
  },
  {
    "path": "Python3/ex16-studydrills2.py",
    "content": "#!/usr/bin/env python3\n\n# A script similar to ex16 that uses read and argv to read the file\n\nfrom sys import argv\n\nscript, filename = argv\n\nprint(\"The contents of the file %s:\" % filename)\ntarget = open(filename)\ncontents = target.read()\nprint(contents)\ntarget.close()"
  },
  {
    "path": "Python3/ex16.py",
    "content": "#!/usr/bin/env python3\n\n# ex16: Reading and Writing Files\n\nfrom sys import argv\n\nscript, filename = argv\n\nprint(\"We're going to erase %r.\" % filename)\nprint(\"If you don't want that, hit CTRL-C (^C).\")\nprint(\"If you do want that, hit RETURN.\")\n\ninput(\"?\")\n\nprint(\"Opening the file...\")\ntarget = open(filename, 'w')\n\nprint(\"Truncating the file.  Goodbye!\")\ntarget.truncate()\n\nprint(\"Now I'm going to ask you for three lines.\")\n\nline1 = input(\"line 1: \")\nline2 = input(\"line 2: \")\nline3 = input(\"line 3: \")\n\nprint(\"I'm going to write these to the file.\")\n\ntarget.write(line1)\ntarget.write(\"\\n\")\ntarget.write(line2)\ntarget.write(\"\\n\")\ntarget.write(line3)\ntarget.write(\"\\n\")\n\nprint(\"And finally, we close it.\")\ntarget.close()"
  },
  {
    "path": "Python3/ex17-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex17: More Files\n\nfrom sys import argv\n\nscript, from_file, to_file = argv\n\nopen(to_file, 'w').write(open(from_file).read())"
  },
  {
    "path": "Python3/ex17.py",
    "content": "#!/usr/bin/env python3\n\n# ex17: More Files\n\nfrom sys import argv\nfrom os.path import exists\n\nscript, from_file, to_file = argv\n\nprint(\"Copying from %s to %s\" % (from_file,to_file))\n\n# we could do these two on one line too, how?\nin_file = open(from_file)\nindata = in_file.read()\n\nprint(\"The input file is %d bytes long\" % len(indata))\n\nprint(\"Does the output file exist? %r\" % exists(to_file))\nprint(\"Ready, hit RETURN to continue, CTRL-C to abort.\")\ninput()\n\nout_file = open(to_file, 'w')\nout_file.write(indata)\n\nprint(\"Alright, all done\")\n\nout_file.close()\nin_file.close()"
  },
  {
    "path": "Python3/ex18.py",
    "content": "#!/usr/bin/env python3\n\n# ex18: Names, Variables, Code, Functions\n\n# this one is like your scripts with argv\ndef print_two(*args):\n    arg1, arg2 = args\n    print(\"arg1: %r, arg2: %r\" % (arg1, arg2))\n\n# ok, that *args is actually pointless, we can just do this\ndef print_two_again(arg1, arg2):\n    print(\"arg1: %r, arg2: %r\" % (arg1, arg2))\n\n# this just takes one argument\ndef print_one(arg1):\n    print(\"arg1: %r\" % arg1)\n\n# this one takes no arguments\ndef print_none():\n    print(\"I got nothin'.\")\n\nprint_two(\"Zed\",\"Shaw\")\nprint_two_again(\"Zed\",\"Shaw\")\nprint_one(\"First!\")\nprint_none()"
  },
  {
    "path": "Python3/ex19-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex19: Functions and Variables\n\n# Import argv variables from the sys module\nfrom sys import argv\n\n# Assign the first and the second arguments to the two variables\nscript, input_file = argv\n\n# Define a function called print_call to print the whole contents of a\n# file, with one file object as formal parameter\ndef print_all(f):\n    # print the file contents\n    print f.read()\n\n# Define a function called rewind to make the file reader go back to\n# the first byte of the file, with one file object as formal parameter\ndef rewind(f):\n    # make the file reader go back to the first byte of the file\n    f.seek(0)\n\n# Define a function called print_a_line to print a line of the file,\n# with a integer counter and a file object as formal parameters\ndef print_a_line(line_count, f):\n    # print the number and the contents of a line\n    print line_count, f.readline()\n\n# Open a file\ncurrent_file = open(input_file)\n\n# Print \"First let's print the whole file:\"\nprint \"First let's print the whole file:\\n\"\n\n# call the print_all function to print the whole file\nprint_all(current_file)\n\n# Print \"Now let's rewind, kind of like a tape.\"\nprint \"Now let's rewind, kind of like a tape.\"\n\n# Call the rewind function to go back to the beginning of the file\nrewind(current_file)\n\n# Now print three lines from the top of the file\n\n# Print \"Let's print three lines:\"\nprint \"Let's print three lines:\"\n\n# Set current line to 1\ncurrent_line = 1\n# Print current line by calling print_a_line function\nprint_a_line(current_line, current_file)\n\n# Set current line to 2 by adding 1\ncurrent_line = current_line + 1\n# Print current line by calling print_a_line function\nprint_a_line(current_file, current_file)\n\n# Set current line to 3 by adding 1\ncurrent_line = current_line + 1\n# Print current line by calling print_a_line function\ncurrent_line(current_line, current_file)\n\n# Define a function named \"cheese_and_crackers\"\ndef cheese_and_crackers(cheese_count, boxes_of_crackers):\n    print(\"You have %d cheeses!\" % cheese_count)\n    print(\"You have %d boxes of crackers!\" % boxes_of_crackers)\n    print(\"Man that's enough for a party!\")\n    print(\"Get a blanket.\\n\")\n\n# Print \"We can just give the function numbers directly:\"\nprint(\"We can just give the function numbers directly:\")\ncheese_and_crackers(20, 30)\n\n# Print \"OR, we can use variables from our script:\"\nprint(\"OR, we can use variables from our script:\")\n# assign 10 to a variable named amount_of_cheese\namount_of_cheese = 10\n# assign 50 to a variable named amount_of_crackers\namount_of_crackers = 50\n\n# Call the function, with 2 variables as the actual parameters\ncheese_and_crackers(amount_of_cheese, amount_of_crackers)\n\n# Print \"We can even do math inside too:\"\nprint(\"We can even do math inside too:\")\n# Call the function, with two math expression as the actual\n# parameters. Python will first calculate the expressions and then\n# use the results as the actual parameters \ncheese_and_crackers(10 + 20, 5 + 6)\n\n# Print \"And we can combine the two, variables and math:\"\nprint(\"And we can combine the two, variables and math:\")\n# Call the function, with two expression that consists of variables\n# and math as the actual parameters\ncheese_and_crackers(amount_of_cheese + 100, amount_of_cheese + 1000)\n\ndef print_args(*argv):\n    size = len(argv)\n    print(size)\n    print(\"Hello! Welcome to use %r!\" % argv[0])\n    if size > 1:\n        for i in range(1, size):\n            print(\"The param %d is %r\" % (i, argv[i]))\n        return 0\n    return -1\n\n# 1. use numbers as actual parameters\nprint_args(10, 20, 30)\n\n# 2. use string and numbers as actual parameters\nprint_args(\"print_args\", 10, 20)\n\n# 3. use strings as actual parameters\nprint_args(\"print_args\", \"Joseph\", \"Pan\")\n\n# 4. use variables as actual parameters\nfirst_name = \"Joseph\"\nlast_name = \"Pan\"\nprint_args(\"print_args\", first_name, last_name)\n\n# 5. contain math expressions\nprint_args(\"print_args\", 5*4, 2.0/5)\n\n# 6. more complicated calculations\nprint_args(\"print_args\", '.'*10, '>'*3)\n\n# 7. more parameters\nprint_args(\"print_args\", 10, 20, 30, 40, 50)\n\n# 8. tuples as parameters\nnums1 = (10, 20, 30)\nnums2 = (40, 50, 60)\nprint_args(\"print_args\", nums1, nums2)\n\n# 9. more complicated types\nnums3 = [70, 80, 90]\nset1 = {\"apple\", \"banana\", \"orange\"}\ndict1 = {'id': '0001', 'name': first_name+\" \"+last_name}\nstr1 = \"Wow, so complicated!\"\nprint_args(\"print args\", nums1, nums2, nums3, set1, dict1, str1)\n\n# 10. function as parameter and with return values\nif print_args(cheese_and_crackers, print_args) != -1:\n    print(\"You just send more than one parameter. Great!\")"
  },
  {
    "path": "Python3/ex19.py",
    "content": "#!/usr/bin/env python3\n\n# ex19: Functions and Variables\n\ndef cheese_and_crackers(cheese_count, boxes_of_crackers):\n    print(\"You have %d cheeses!\" % cheese_count)\n    print(\"You have %d boxes of crackers!\" % boxes_of_crackers)\n    print(\"Man that's enough for a party!\")\n    print(\"Get a blanket.\\n\")\n\nprint(\"We can just give the function numbers directly:\")\ncheese_and_crackers(20, 30)\n\nprint(\"OR, we can use variables from our script:\")\namount_of_cheese = 10\namount_of_crackers = 50\n\ncheese_and_crackers(amount_of_cheese, amount_of_crackers)\n\nprint(\"We can even do math inside too:\")\ncheese_and_crackers(10 + 20, 5 + 6)\n\nprint(\"And we can combine the two, variables and math:\")\ncheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 1000)"
  },
  {
    "path": "Python3/ex20-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex20: Functions and Files\n\n# Import argv variables from the sys module\nfrom sys import argv\n\n# Assign the first and the second arguments to the two variables\nscript, input_file = argv\n\n# Define a function called print_call to print the whole contents of a\n# file, with one file object as formal parameter\ndef print_all(f):\n    # print the file contents\n    print(f.read())\n\n# Define a function called rewind to make the file reader go back to\n# the first byte of the file, with one file object as formal parameter\ndef rewind(f):\n    # make the file reader go back to the first byte of the file\n    f.seek(0)\n\n# Define a function called print_a_line to print a line of the file,\n# with a integer counter and a file object as formal parameters\ndef print_a_line(line_count, f):\n    # Test whether two variables are carrying the same value\n    print(\"line_count equal to current_line?:\", (line_count == current_line))\n    # print the number and the contents of a line\n    print(line_count, f.readline())\n\n# Open a file\ncurrent_file = open(input_file)\n\n# Print \"First let's print the whole file:\"\nprint(\"First let's print the whole file:\\n\")\n\n# call the print_all function to print the whole file\nprint_all(current_file)\n\n# Print \"Now let's rewind, kind of like a tape.\"\nprint(\"Now let's rewind, kind of like a tape.\")\n\n# Call the rewind function to go back to the beginning of the file\nrewind(current_file)\n\n# Now print three lines from the top of the file\n\n# Print \"Let's print three lines:\"\nprint(\"Let's print three lines:\")\n\n# Set current line to 1\ncurrent_line = 1\n# Print current line by calling print_a_line function\nprint_a_line(current_line, current_file)\n\n# Set current line to 2 by adding 1\ncurrent_line += 1\n# Print current line by calling print_a_line function\nprint_a_line(current_line, current_file)\n\n# Set current line to 3 by adding 1\ncurrent_line += 1\n# Print current line by calling print_a_line function\nprint_a_line(current_line, current_file)\n"
  },
  {
    "path": "Python3/ex20.py",
    "content": "#!/usr/bin/env python3\n\n# ex20: Functions and Files\n\nfrom sys import argv\n\nscript, input_file = argv\n\ndef print_all(f):\n    print(f.read())\n\ndef rewind(f):\n    f.seek(0)\n\ndef print_a_line(line_count, f):\n    print(line_count, f.readline())\n\ncurrent_file = open(input_file)\n\nprint(\"First let's print the whole file:\\n\")\n\nprint_all(current_file)\n\nprint(\"Now let's rewind, kind of like a tape.\")\n\nrewind(current_file)\n\nprint(\"Let's print three lines:\")\n\ncurrent_line = 1\nprint_a_line(current_line, current_file)\n\ncurrent_line = current_line + 1\nprint_a_line(current_line, current_file)\n\ncurrent_line = current_line + 1\nprint_a_line(current_line, current_file)"
  },
  {
    "path": "Python3/ex21-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex21: Functions Can Return Something\n\ndef add(a, b):\n    print(\"ADDING %d + %d\" % (a, b))\n    return a + b\n\ndef subtract(a, b):\n    print(\"SUBTRACTING %d - %d\" % (a, b))\n    return a - b\n\ndef multiply(a, b):\n    print(\"MULTIPLYING %d * %d\" % (a, b))\n    return a * b\n\ndef divide(a, b):\n    print(\"DIVIDING %d / %d\" % (a, b))\n    return a / b\n\n# my function to test return\ndef isequal(a, b):\n    print(\"Is %r equal to %r? - \" % (a, b), end=\"\")\n    return (a == b)\n\nprint(\"Let's do some math with just functions!\")\n\nage = add(30, 5)\nheight = subtract(78, 4)\nweight = multiply(92, 2)\niq = divide(100, 2)\n\nprint(\"Age: %d, Height: %d, Weight: %d, IQ: %d\" % (age, height, weight, iq))\n\n\n# A puzzle for the extra credit, type it in anyway.\nprint(\"Here is a puzzle.\")\n\n# switch the order of multiply and divide\nwhat = add(age, subtract(height, divide(weight, multiply(iq, 2))))\n\nprint(\"That becomes: \", what, \"Can you do it by hand?\")\n\n# test the return value of isequal()\nnum1 = 40\nnum2 = 50\nnum3 = 50\n\nprint(isequal(num1, num2))\nprint(isequal(num2, num3))\n\n\n# A new puzzle.\nprint(\"Here is a new puzzle.\")\n\n# write a simple formula and use the function again\nuplen = 50\ndownlen = 100\nheight = 80\nwhat_again = divide(multiply(height, add(uplen, downlen)), 2)\n\nprint(\"That become: \", what_again, \"Bazinga!\")"
  },
  {
    "path": "Python3/ex21.py",
    "content": "#!/usr/bin/env python3\n\n# ex21: Functions Can Return Something\n\ndef add(a, b):\n    print(\"ADDING %d + %d\" % (a, b))\n    return a + b\n\ndef subtract(a, b):\n    print(\"SUBTRACTING %d - %d\" % (a, b))\n    return a - b\n\ndef multiply(a, b):\n    print(\"MULTIPLYING %d * %d\" % (a, b))\n    return a * b\n\ndef divide(a, b):\n    print(\"DIVIDING %d / %d\" % (a, b))\n    return a / b\n\nprint(\"Let's do some math with just functions!\")\n\nage = add(30, 5)\nheight = subtract(78, 4)\nweight = multiply(92, 2)\niq = divide(100, 2)\n\nprint(\"Age: %d, Height: %d, Weight: %d, IQ: %d\" % (age, height, weight, iq))\n\n\n# A puzzle for the extra credit, type it in anyway.\nprint(\"Here is a puzzle.\")\n\nwhat = add(age, subtract(height, divide(weight, multiply(iq, 2))))\n\nprint(\"That becomes: \", what, \"Can you do it by hand?\")"
  },
  {
    "path": "Python3/ex24-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex24: More Practice\n\nprint(\"Let's practice everything.\")\nprint(\"You\\'d need to know \\'bout escapes with \\\\ that do \\n newlines and \\t tabs.\")\n\npoem = \"\"\"\n\\t The lovely world\nwith logic so firmly planted\ncannot discern \\n the needs of love\nnor comprehend passion from intuition\nand requires an explanation\n\\n\\t\\twhere there is none.\n\"\"\"\n\nprint(\"--------------------\")\nprint(poem)\nprint(\"--------------------\")\n\n\nfive = 10 - 2 + 3 - 6\nprint(\"This should be five: %s\" % five)\n\ndef secret_formala(started):\n    jelly_beans = started * 500\n    jars = jelly_beans / 1000\n    crates = jars / 100\n    return jelly_beans, jars, crates\n\n\nstart_point = 1000\nbeans, jars, crates = secret_formala(start_point)\n\nprint(\"With a starting point of: %d\" % start_point)\n# use the tuple as the parameters for the formatter\nprint(\"We'd have %d beans, %d jars, and %d crates.\" % (beans, jars, crates))\n\nstart_point = start_point / 10\n\nprint(\"We can also do that this way:\")\n# call the function and use its return values as the parameters for the formatter\nprint(\"We'd have %d beans, %d jars, and %d crates.\" % secret_formala(start_point))\n"
  },
  {
    "path": "Python3/ex24.py",
    "content": "#!/usr/bin/env python3\n\n# ex24: More Practice\n\nprint(\"Let's practice everything.\")\nprint(\"You\\'d need to know \\'bout escapes with \\\\ that do \\n newlines and \\t tabs.\")\n\npoem = \"\"\"\n\\t The lovely world\nwith logic so firmly planted\ncannot discern \\n the needs of love\nnor comprehend passion from intuition\nand requires an explanation\n\\n\\t\\twhere there is none.\n\"\"\"\n\nprint(\"--------------------\")\nprint(poem)\nprint(\"--------------------\")\n\n\nfive = 10 - 2 + 3 - 6\nprint(\"This should be five: %s\" % five)\n\ndef secret_formala(started):\n    jelly_beans = started * 500\n    jars = jelly_beans / 1000\n    crates = jars / 100\n    return jelly_beans, jars, crates\n\n\nstart_point = 1000\nbeans, jars, crates = secret_formala(start_point)\n\nprint(\"With a starting point of: %d\" % start_point)\nprint(\"We'd have %d beans, %d jars, and %d crates.\" % (beans, jars, crates))\n\nstart_point = start_point / 10\n\nprint(\"We can also do that this way:\")\nprint(\"We'd have %d beans, %d jars, and %d crates.\" % secret_formala(start_point))\n"
  },
  {
    "path": "Python3/ex25.py",
    "content": "#!/usr/bin/env python3\n\n# ex: even more practice\n\ndef break_words(stuff):\n    \"\"\" This function will break up words for us. \"\"\"\n    words = stuff.split(' ')\n    return words\n\ndef sort_words(words):\n    \"\"\" Sorts the words. \"\"\"\n    return sorted(words)\n\ndef print_first_word(words):\n    \"\"\" Prints the first word after popping it off. \"\"\"\n    word = words.pop(0)\n    print(word)\n\ndef print_last_word(words):\n    \"\"\" Prints the last word after popping it off. \"\"\"\n    word = words.pop(-1)\n    print(word)\n\ndef sort_sentence(sentence):\n    \"\"\" Takes in a full sentence and returns the sorted words. \"\"\"\n    words = break_words(sentence)\n    return sort_words(words)\n\ndef print_first_and_last(senence):\n    \"\"\" Prints the first and last words of the sentences. \"\"\"\n    words = break_words(senence)\n    print_first_word(words)\n    print_last_word(words)\n\ndef print_first_and_last_sorted(sentence):\n    \"\"\" Sorts the words then prints the first and last one. \"\"\"\n    words = sort_sentence(sentence)\n    print_first_word(words)\n    print_last_word(words)"
  },
  {
    "path": "Python3/ex26.py",
    "content": "#!/usr/bin/env python3\n\ndef break_words(stuff):\n    \"\"\"This function will break up words for us.\"\"\"\n    words = stuff.split(' ')\n    return words\n\ndef sort_words(words):\n    \"\"\"Sorts the words.\"\"\"\n    return sorted(words)\n\n# bug: def print_first_word(words)\ndef print_first_word(words):\n    \"\"\"Prints the first word after popping it off.\"\"\"\n    # bug: word = words.poop(0)\n    word = words.pop(0)\n    # bug: print word\n    print(word)\n\ndef print_last_word(words):\n    \"\"\"Prints the last word after popping it off.\"\"\"\n    # bug: word = words.pop(-1\n    word = words.pop(-1)\n    # bug: print word\n    print(word)\n\ndef sort_sentence(sentence):\n    \"\"\"Takes in a full sentence and returns the sorted words.\"\"\"\n    words = break_words(sentence)\n    return sort_words(words)\n\ndef print_first_and_last(sentence):\n    \"\"\"Prints the first and last words of the sentence.\"\"\"\n    words = break_words(sentence)\n    print_first_word(words)\n    print_last_word(words)\n\ndef print_first_and_last_sorted(sentence):\n    \"\"\"Sorts the words then prints the first and last one.\"\"\"\n    words = sort_sentence(sentence)\n    print_first_word(words)\n    print_last_word(words)\n\n\n# bug: print \"Let's practice everything.\"\nprint(\"Let's practice everything.\")\n# bug: print 'You\\'d need to know \\'bout escapes with \\\\ that do \\n newlines and \\t tabs.'\nprint('You\\'d need to know \\'bout escapes with \\\\ that do \\n newlines and \\t tabs.')\n\npoem = \"\"\"\n\\tThe lovely world\nwith logic so firmly planted\ncannot discern \\n the needs of love\nnor comprehend passion from intuition\nand requires an explantion\n\\n\\t\\twhere there is none.\n\"\"\"\n\n# bug: print \"--------------\"\nprint(\"--------------\")\n# bug: print poem\nprint(poem)\n# bug: print \"--------------\"\nprint(\"--------------\")\n\n# warning: it's not five\nfive = 10 - 2 + 3 - 5\n# bug: print \"This should be five: %s\" % five\nprint(\"This should be five: %s\" % five)\n\n\ndef secret_formula(started):\n    jelly_beans = started * 500\n    # bug: jars = jelly_beans \\ 1000\n    jars = jelly_beans / 1000\n    crates = jars / 100\n    return jelly_beans, jars, crates\n\n\nstart_point = 10000\n# bug: beans, jars, crates == secret_formula(start-point)\nbeans, jars, crates = secret_formula(start_point)\n\n# bug: print \"With a starting point of: %d\" % start_point\nprint(\"With a starting point of: %d\" % start_point)\n# bug: print \"We'd have %d jeans, %d jars, and %d crates.\" % (beans, jars, crates)\nprint(\"We'd have %d jeans, %d jars, and %d crates.\" % (beans, jars, crates))\n\nstart_point = start_point / 10\n\n# bug: print \"We can also do that this way:\"\nprint(\"We can also do that this way:\")\n# bug: print \"We'd have %d beans, %d jars, and %d crabapples.\" %\n# secret_formula(start_pont\nprint(\"We'd have %d beans, %d jars, and %d crabapples.\" % secret_formula(start_point))\n\n\n# bug: sentence = \"All god\\tthings come to those who weight.\"\nsentence = \"All good things come to those who weight.\"\n\n# bug: words = ex25.break_words(sentence)\nwords = break_words(sentence)\n# bug: sorted_words = ex25.sort_words(words)\nsorted_words = sort_words(words)\n\nprint_first_word(words)\nprint_last_word(words)\n# bug: .print_first_word(sorted_words)\nprint_first_word(sorted_words)\nprint_last_word(sorted_words)\n# bug: sorted_words = ex25.sort_sentence(sentence)\nsorted_words = sort_sentence(sentence)\n# bug: prin sorted_words\nprint(sorted_words)\n# bug: print_irst_and_last(sentence)\nprint_first_and_last(sentence)\n\n# bug:   print_first_a_last_sorted(senence)\nprint_first_and_last_sorted(sentence)"
  },
  {
    "path": "Python3/ex29-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex29: What If\n\npeople = 20\ncats = 30\ndogs = 15\n\nif people < cats:\n    print(\"Too many cats! The world is doomed!\")\n\nif people > cats:\n    print(\"Not many cats! The world is saved!\")\n\nif people < dogs:\n    print(\"The world is drooled on!\")\n\nif people > dogs:\n    print(\"The world is dry!\")\n\ndogs += 5\n\nif people >= dogs:\n    print(\"People are greater than or equal to dogs.\")\n\nif people <= dogs:\n    print(\"People are less than or equal to dogs.\")\n\nif people == dogs:\n    print(\"People are dogs.\")\n\ndogs += 5\n\nif (dogs < cats) and (people < cats):\n    print(\"Cats are more than people and dogs. People are scared by cats!\")    \n\nif (dogs < cats) and not (people < cats):\n    print(\"Cats are more than dogs. Mice are living a hard life!\")\n    \nif (dogs == cats) or (cats < 10):\n    print(\"Cats are fighting against dogs! Mice are happy!\")\n\nif cat != 0: \n    print(\"Cats are still exist. Mice cannot be too crazy.\")  "
  },
  {
    "path": "Python3/ex29.py",
    "content": "#!/usr/bin/env python3\n\n# ex29: What If\n\npeople = 20\ncats = 30\ndogs = 15\n\nif people < cats:\n    print(\"Too many cats! The world is doomed!\")\n\nif people > cats:\n    print(\"Not many cats! The world is saved!\")\n\nif people < dogs:\n    print(\"The world is drooled on!\")\n\nif people > dogs:\n    print(\"The world is dry!\")\n\ndogs += 5\n\nif people >= dogs:\n    print(\"People are greater than or equal to dogs.\")\n\nif people <= dogs:\n    print(\"People are less than or equal to dogs.\")\n\nif people == dogs:\n    print(\"People are dogs.\")"
  },
  {
    "path": "Python3/ex30-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex30: Else and If\n\n# assign 30 to variable people\npeople = 30\n# assign 40 to variable cars\ncars = 40\n# assign 15 to variable buses\nbuses = 15\n\n# if cars are more than people\nif cars > people:\n    # print \"We should take the cars.\"\n    print(\"We should take the cars.\")\n# if cars are less than people\nelif cars < people:\n    # print \"We should not take the cars\"\n    print(\"We should not take the cars\")\n# if cars are equal to people\nelse:\n    print(\"We can't decide.\")\n\n# if buses are more than cars    \nif buses > cars:\n    # print \"That's too many buses.\"\n    print(\"That's too many buses.\")\n# if buses are less than cars    \nelif buses < cars:\n    # print \"Maybe we could take the buses.\"\n    print(\"Maybe we could take the buses.\")\n# if buses are equal to cars    \nelse:\n    # print \"We still can't decide.\"\n    print(\"We still can't decide.\")\n\n# if people are more than buses\nif people > buses:\n    # print \"Alright, let's just take the buses.\"\n    print(\"Alright, let's just take the buses.\")\n# if people are less than buses\nelse:\n    # print \"Fine, let's stay home then.\"\n    print(\"Fine, let's stay home then.\")\n\n# if people are more than cars but less than buses\nif people > cars and people < buses:\n    # print \"There are many Busses but few cars.\"\n    print(\"There are many Busses but few cars.\")\n# if people are less than cars but more than buses\nelif people < cars and people > buses:\n    # print \"There are many cars but few busses.\"\n    print(\"There are many cars but few busses.\")\n# if people are more than cars and buses\nelif people > cars and people > buses:\n    # print \"There are few busses and cars.\"\n    print(\"There are few busses and cars.\")\n# if people are less than cars and buses    \nelse:\n    # print \"There are many busses and cars.\"\n    print(\"There are many busses and cars.\")"
  },
  {
    "path": "Python3/ex30.py",
    "content": "#!/usr/bin/env python3\n\n# ex30: Else and If\n\npeople = 30\ncars = 40\nbuses = 15\n\nif cars > people:\n    print(\"We should take the cars.\")\nelif cars < people:\n    print(\"We should not take the cars\")\nelse:\n    print(\"We can't decide.\")\n\nif buses > cars:\n    print(\"That's too many buses.\")\nelif buses < cars:\n    print(\"Maybe we could take the buses.\")\nelse:\n    print(\"We still can't decide.\")\n\nif people > buses:\n    print(\"Alright, let's just take the buses.\")\nelse:\n    print(\"Fine, let's stay home then.\")"
  },
  {
    "path": "Python3/ex31-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex31: Making Decisions\n\nprint(\"You enter a dark room with two doors. Do you go through door #1 or door #2?\")\n\ndoor = input(\"> \")\n\nif door == \"1\":\n    print(\"There's a giant bear here eating a cheese cake. What do you do?\")\n    print(\"1. Take the cake.\")\n    print(\"2. Scream at the bear.\")\n\n    bear = input(\"> \")\n\n    if bear == \"1\":\n        print(\"The bear eats your face off. Good job!\")\n    elif bear == \"2\":\n        print(\"The bear eats your legs off. Good job!\")\n    else:\n        print(\"Well, doing %s is probably better. Bear runs away.\" % bear)\n\nelif door == \"2\":\n    print(\"You stare into the endless abyss at Cthulhu's retina.\")\n    print(\"1. Blueberries.\")\n    print(\"2. Yellow jacket clothespins.\")\n    print(\"3. Understanding revolvers yelling melodies.\")\n\n    insanity = input(\"> \")\n\n    if insanity == \"1\" or insanity == \"2\":\n        print(\"Your body survives powered by a mind of jello. Good job!\")\n    else:\n        print(\"The insanity rots you \")\n\nelif door == \"3\":\n    print(\"You are asked to select one pill from two and take it. One is red, and the other is blue.\")\n    print(\"1. take the red one.\")\n    print(\"2. take the blue one.\")\n\n    pill = input(\"> \")\n\n    if pill == \"1\":\n        print(\"You wake up and found this is just a ridiculous dream. Good job!\")\n    elif pill == \"2\":\n        print(\"It's poisonous and you died.\")\n    else:\n        print(\"The man got mad and killed you.\")\n\nelse:\n    print(\"You wake up and found this is just a ridiculous dream.\")\n    print(\"However you feel a great pity haven't entered any room and found out what it will happens!\")"
  },
  {
    "path": "Python3/ex31.py",
    "content": "#!/usr/bin/env python3\n\n# ex31: Making Decisions\n\nprint(\"You enter a dark room with two doors. Do you go through door #1 or door #2?\")\n\ndoor = input(\"> \")\n\nif door == \"1\":\n    print(\"There's a giant bear here eating a cheese cake. What do you do?\")\n    print(\"1. Take the cake.\")\n    print(\"2. Scream at the bear.\")\n\n    bear = input(\"> \")\n\n    if bear == \"1\":\n        print(\"The bear eats your face off. Good job!\")\n    elif bear == \"2\":\n        print(\"The bear eats your legs off. Good job!\")\n    else:\n        print(\"Well, doing {} is probably better. Bear runs away.\".format(bear))\n    \nelif door == \"2\":\n    print(\"You stare into the endless abyss at Cthulhu's retina.\")\n    print(\"1. Blueberries.\")\n    print(\"2. Yellow jacket clothespins.\")\n    print(\"3. Understanding revolvers yelling melodies.\")\n    \n    insanity = input(\"> \")\n    \n    if insanity == \"1\" or insanity == \"2\":\n        print(\"Your body survives powered by a mind of a jello. good job!\")\n    else:\n        print(\"The insanity roots your eyes into a pool of muck. Good job!\")\n\nelse:\n    print(\"You stumble around and fall on a knife and die. Good job!\")"
  },
  {
    "path": "Python3/ex32.py",
    "content": "#!/usr/bin/env python3\n\n# ex32: Loops and Lists\n\nthe_count = [1, 2, 3, 4, 5]\nfruits = ['apples', 'oranges', 'pears', 'apricots']\nchange = [1, 'pennies', 2, 'dimes', 3, 'quarters']\n\n# this first kind of for-loop goes through a list\nfor number in the_count:\n    print(\"This is count %d\" % number)\n\n# same as above\nfor fruit in fruits:\n    print(\"A fruit of type: %s\" % fruit)\n\n# also we can go through mixed lists too\n# notice we have to use %r since we don't know what's in it\nfor i in change:\n    print(\"I got %r\" % i)\n\n# we can also build lists, first start with an empty one\nelements = []\n\n# then use the range function to generate a list\nelements = range(0, 6)\n    \n# now we can print them out too\nfor i in elements:\n    print(\"Element was: %d\" % i)"
  },
  {
    "path": "Python3/ex33-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex33: While Loops\n\ndef createNumbers(max, step):\n    i = 0\n    numbers = []\n    for i in range(0, max, step):\n        print(\"At the top i is %d\" % i)\n        numbers.append(i)\n\n        print(\"Numbers now: \", numbers)\n        print(\"At the bottom i is %d\" % i)\n    return numbers \n\nnumbers = createNumbers(10, 2)\n\nprint(\"The number: \")\n\nfor num in numbers:\n    print(num)"
  },
  {
    "path": "Python3/ex33.py",
    "content": "#!/usr/bin/env python3\n\n# ex33: While Loops\n\ni = 0\nnumbers = []\n\nwhile i < 6:\n    print(\"At the top i is {}\".format(i))\n    numbers.append(i)\n    \n    i = i + 1\n    print(\"Numbers now: \", numbers)\n    print(\"At the bottom i is {}\".format(i))\n\nprint(\"The numbers:\")\n\nfor num in numbers:\n    print(num)"
  },
  {
    "path": "Python3/ex34.py",
    "content": "#!/usr/bin/env python3\n\n# ex34: Accessing Elements of Lists\n\nanimals = ['bear', 'python', 'peacock', 'kangaroo', 'whale', 'platypus']\n\ndef printAnimal(index):\n    if index == 1:\n        num2en = \"1st\"\n    elif index == 2:\n        num2en = \"2nd\"\n    elif index == 3:\n        num2en = \"3rd\"\n    else:\n        num2en = str(index)+\"th\"\n    print(\"The %s animal is at %d and is a %s\" % (num2en, index-1, animals[index-1]))\n    print(\"The animal at %d is the %s animal and is a %s\" % (index-1, num2en, animals[index-1]))\n\nfor i in range(1, 7):\n    printAnimal(i)"
  },
  {
    "path": "Python3/ex35.py",
    "content": "#!/usr/bin/env python3\n\n# ex35: Branches and Functions\n\nfrom sys import exit\n\ndef gold_room():\n    ''' A room with full of god. '''    \n    print(\"This room is full of gold.  How much do you take?\")\n\n    next = input(\"> \")\n\n    try:\n        how_much = int(next)\n    except ValueError:\n        dead(\"Man, learn to type a number.\")\n\n    if how_much < 50:\n        print(\"Nice, you're not greedy, you win!\")\n        exit(0)\n    else:\n        dead(\"You greedy bastard!\")\n\n\ndef bear_room():\n    ''' A room with a bear '''    \n    print(\"There is a bear here.\")\n    print(\"The bear has a bunch of honey.\")\n    print(\"The fat bear is in front of another door.\")\n    print(\"How are you going to move the bear?\")\n    bear_moved = False\n\n    while True:\n        next = input(\"> \")\n\n        if next == \"take honey\":\n            dead(\"The bear looks at you then slaps your face off.\")\n        elif next == \"taunt bear\" and not bear_moved:\n            print(\"The bear has moved from the door. You can go through it now.\")\n            bear_moved = True\n        elif next == \"taunt bear\" and bear_moved:\n            dead(\"The bear gets pissed off and chews your leg off.\")\n        elif next == \"open door\" and bear_moved:\n            gold_room()\n        else:\n            print(\"I got no idea what that means.\")\n\n\ndef cthulhu_room():\n    ''' A room with evil Cthulhu '''\n    print(\"Here you see the great evil Cthulhu.\")\n    print(\"He, it, whatever stares at you and you go insane.\")\n    print(\"Do you flee for your life or eat your head?\")\n\n    next = input(\"> \")\n\n    if \"flee\" in next:\n        start()\n    elif \"head\" in next:\n        dead(\"Well that was tasty!\")\n    else:\n        cthulhu_room()\n\n\ndef dead(why):\n    ''' Call this when the hero dead '''\n    print(why, \"Good job!\")\n    exit(0)\n\ndef start():\n    ''' Begining of the story '''\n    print(\"You are in a dark room.\")\n    print(\"There is a door to your right and left.\")\n    print(\"Which one do you take?\")\n\n    next = input(\"> \")\n\n    if next == \"left\":\n        bear_room()\n    elif next == \"right\":\n        cthulhu_room()\n    else:\n        dead(\"You stumble around the room until you starve.\")\n\nstart()"
  },
  {
    "path": "Python3/ex37.py",
    "content": "#!/usr/bin/env python3\n\n# ex37: Symbol Review\n\n# and, or, not, if, elif, else\n\nprint(\"#1##############################\")\n\nif True and False:\n    print(\"#1 can't be printed\")\n\nif False and False:\n    print(\"#2 can't be printed\")\n\nif True and True:\n    print(\"#3 can be printed!\")\n\nif False or True:\n    print(\"#4 can be printed!\")\n\nif True or False:\n    print(\"#5 can be printed!\")\n\nif True or No_Matter_What:\n    print(\"#6 can be printed!\")\n\nif not(False and No_Matter_What):\n    print(\"#7 can be printed!\")\n\nrainy = True\nsunny = False\nif rainy:\n    print(\"It's rainny today!\")\nelif sunny:\n    print(\"It's sunny today!\")\nelse:\n    print(\"It's neither rainny nor sunny today!\")\n\n\n# del, try, except, as\n\nprint(\"#2##############################\")\n\nx = 10\nprint(x)\n\ndel x\ntry:\n    print(x)\nexcept NameError as er:\n    print(er)\n\n    \n# from, import\n\nprint(\"#3##############################\")\n\nfrom sys import argv\nscript = argv\nprint(\"The script name is %s \" % script)\n\n# for, in\nfor i in range(0, 10):\n    print(i, end=' ')\n\n# assert\ntry:\n    assert True, \"\\nA True!\"\n    assert False, \"\\nA false!\"\nexcept AssertionError as er:\n    print(er)\n\n# global, def\nprint(\"#4##############################\")\nx = 5\n\ndef addone():\n    # annouce that x is the global x\n    global x\n    x += 1\n\naddone()\nprint(\"x is %d\", x)\n\n# finally\n\nprint(\"#4##############################\")\n\nimport time\ntry:\n    f = open('sample.txt')\n    while True: # our usual file-reading idiom\n        line = f.readline()\n        if len(line) == 0:\n            break\n        print(line) \nexcept KeyboardInterrupt:\n    print('!! You cancelled the reading from the file.')\nfinally:\n    f.close()\n    print('(Cleaning up: Closed the file)')\n    \n# with\n\nprint(\"#5##############################\")\n\nwith open(\"sample.txt\") as f:\n    print(f.read())\n\n# pass, class\n\nprint(\"#6##############################\")\n\nclass NoneClass:\n    ''' Define an empty class. '''\n    pass\n\nempty = NoneClass()\nprint(empty)\n\nclass Droid:\n    ''' Define a robot with a name. '''\n    def __init__(self, name):\n        self.name = name\n        print(\"Robot %s initialized.\" % self.name)\n    def __del__(self):\n        print(\"Robot %s destroyed.\" % self.name)\n    def sayHi(self):\n        print(\"Hi, I'm %s.\" % self.name)\n\nr2d2 = Droid('R2D2')\nr2d2.sayHi()\ndel r2d2\n\n# exec\n\nprint(\"#7##############################\")\n\nprint(\"Here I will use exec function to calculate 5 + 2\")\nexec(\"print('5 + 2 =', 5 + 2)\")\n\n# while, break\n\nprint(\"#8##############################\")\n\nwhile True:\n    try:\n        num = int(input(\"Let's guess an integer:\"))\n        if num > 10:\n            print(\"too big!\")\n        elif num < 10:\n            print(\"too small!\")\n        else:\n            print(\"Congrats! You will!\")\n            break\n    except ValueError:\n        print(\"Please insert a value!\")\n\n# raise\n\nprint(\"#9##############################\")\n\nclass ShortInputException(Exception):\n    ''' A user-defined exception class. '''\n    def __init__(self, length, atleast):\n        Exception.__init__(self)\n        self.length = length\n        self.atleast = atleast\ntry:\n    text = input('Enter something long enough --> ')\n    if len(text) < 3:\n        raise ShortInputException(len(text), 3)\n    # Other work can continue as usal here\nexcept EOFError:\n    print('Why did you do an EOF on me?')\nexcept ShortInputException as ex:\n    print('ShortInputException: The input was {0} long, expected at least {1}'\\\n          .format(ex.length, ex.atleast))    \nelse:\n    print('No exception was raised.')\n\n# yield\n\nprint(\"#10##############################\")\n\nprint(\"Now we counter from 1 to 99: \")            \n\ndef make_counter(max):\n    x = 1\n    while x < max:\n        yield x\n        x = x + 1\n\nfor i in make_counter(100):\n    print(i, end=' ')\n\nprint(\"\\n\\nNow we calculate fibonacci series: \")          \n    \ndef fib(max):\n    ''' A fibonacci secries generator.\n\n    Calculates fibonacci numbers from 0 to max.\n     '''\n    a, b = 0, 1\n    while a < max:\n        yield a\n        a, b = b, a+b\n\nfor num in fib(100):\n    print(num, end=' ')\n\n# lambda\n\nprint(\"\\n#11##############################\")\n\ndef makeDouble():\n    ''' double given value '''\n    return lambda x:x * 2\n\nadder = makeDouble()\nnum_list = [5, 10, 15, 'hello']\nprint('\\nNow we multiples each elements in num_list with 2:')\nfor num in num_list:\n    print(adder(num))"
  },
  {
    "path": "Python3/ex38.py",
    "content": "#!/usr/bin/env python3\n\n# ex38: Doing Things To Lists\n\nten_things = \"Apples Oranges Crows Telephone Light Sugar\"\n\nprint(\"Wait there's not 10 things in that list, let's fix that.\")\n\nstuff = ten_things.split(' ')\nmore_stuff = [\"Day\", \"Night\", \"Song\", \"Frisbee\", \"Corn\", \"Banana\", \"Girl\", \"Boy\"]\n\nwhile len(stuff) != 10:\n    next_one = more_stuff.pop()\n    print(\"Adding: \", next_one)\n    stuff.append(next_one)\n    print(\"There's %d items now.\" % len(stuff))\n\nprint(\"There we go: \", stuff)\n\nprint(\"Let's do some things with stuff.\")\n\nprint(stuff[1])\nprint(stuff[-1])  # whoa! fancy\nprint(stuff.pop())\nprint(' '.join(stuff))  # what? cool!\nprint('#'.join(stuff[3:5]))  # super stellar!"
  },
  {
    "path": "Python3/ex39-studydrills.py",
    "content": "#!/bin/python3\n\n# ex39: Dictionaries, Oh Lovely Dictionaries\n\n# create a mapping of state to abbreviation\nstates = {\n    'Oregon': 'OR',\n    'Florida': 'FL',\n    'California': 'CA',\n    'New York': 'NY',\n    'Michigan': 'MI'\n}\n\n# create a basic set of states and some cities in them\ncities = {\n    'CA': 'San Fransisco',\n    'MI': 'Detroit',\n    'FL': 'Jacksonville'\n    }\n\n# add some more cities\ncities['NY'] = 'New York'\ncities['OR'] = 'Portland'\n\n# print out some cities\nprint('-' * 10)\nprint(\"NY State has: \", cities['NY'])\nprint('OR State has: ', cities['OR'])\n\n# do it by using the state then cities dict\nprint('-' * 10)\nprint(\"Michigan has: \", cities[states['Michigan']])\nprint(\"Florida has:\", cities[states['Florida']])\n\n# print every state abbreviation\nprint('-' * 10)\nfor state, abbrev in states.items():\n    print(\"%s is abbreviated %s\" % (state, abbrev))\n\n# print every city in state\nprint('-' * 10)\nfor abbrev, city in cities.items():\n    print(\"%s has the city %s\" % (abbrev, city))\n\n# now do both at the same time\nprint('-' * 10)\nfor state, abbrev in states.items():\n    print(\"%s state is abbreviated %s and has city %s\" % (\n        states, abbrev, cities[abbrev]))\n\nprint('-' * 10)\n# safely get a abbreviation by state that might not be there\nstate = states.get('Texas', None)\n\nif not state:\n    print(\"Sorry, no Texas.\")\n\n# get a city with a default value\ncity = cities.get(\"TX\", 'Does Not Exist')\nprint(\"The city for the state 'TX' is %s\" % city)\n\n# create a mapping of province to abbreviation\ncn_province = {\n    '广东': '粤',\n    '湖南': '湘',\n    '四川': '川',\n    '云南': '滇',\n    }\n\n# create a basic set of provinces and some cities in them\ncn_cities = {\n    '粤': '广州',\n    '湘': '长沙',\n    '川': '成都',\n    }\n\n# add some more data\ncn_province['台湾'] = '台'\n\ncn_cities['滇'] = '昆明'\ncn_cities['台'] = '高雄'\n\nprint('-' * 10)\nfor prov, abbr in cn_province.items():\n    print(\"%s省的缩写是%s\" % (prov, abbr))\n\nprint('-' * 10)\ncn_abbrevs = {values: keys for keys, values in cn_province.items()}\nfor abbrev, prov in cn_abbrevs.items():\n    print(\"%s是%s省的缩写\" % (abbrev, prov))\n\nprint('-' * 10)\nfor abbrev, city in cn_cities.items():\n    print(\"%s市位于我国的%s省\" % (city, cn_abbrevs[abbrev]))\n"
  },
  {
    "path": "Python3/ex39.py",
    "content": "#!/usr/bin/env python3\n\n# ex39: Dictionaries, Oh Lovely Dictionaries\n\n# create a mapping of state to abbreviation\nstates = {\n    'Oregon': 'OR',\n    'Florida': 'FL',\n    'California': 'CA',\n    'New York': 'NY',\n    'Michigan': 'MI'\n}\n\n# create a basic set of states and some cities in them\ncities = {\n    'CA': 'San Fransisco',\n    'MI': 'Detroit',\n    'FL': 'Jacksonville'\n    }\n\n# add some more cities\ncities['NY'] = 'New York'\ncities['OR'] = 'Portland'\n\n# print out some cities\nprint('-' * 10)\nprint(\"NY State has: \", cities['NY'])\nprint('OR State has: ', cities['OR'])\n\n# do it by using the state then cities dict\nprint('-' * 10)\nprint(\"Michigan has: \", cities[states['Michigan']])\nprint(\"Florida has:\", cities[states['Florida']])\n\n# print every state abbreviation\nprint('-' * 10)\nfor state, abbrev in states.items():\n    print(\"%s is abbreviated %s\" % (state, abbrev))\n\n# print every city in state\nprint('-' * 10)\nfor abbrev, city in cities.items():\n    print(\"%s has the city %s\" % (abbrev, city))\n\n# now do both at the same time\nprint('-' * 10)\nfor state, abbrev in states.items():\n    print(\"%s state is abbreviated %s and has city %s\" % (\n        states, abbrev, cities[abbrev]))\n\nprint('-' * 10)\n# safely get a abbreviation by state that might not be there\nstate = states.get('Texas', None)\n\nif not state:\n    print(\"Sorry, no Texas.\")\n\n# get a city with a default value\ncity = cities.get(\"TX\", 'Does Not Exist')\nprint(\"The city for the state 'TX' is %s\" % city)"
  },
  {
    "path": "Python3/ex40-studydrills.py",
    "content": "#!/usr/bin/env python3\n\n# ex40: Modules, CLasses, and Objects\n\nclass Song(object):\n\n    def __init__(self, disk):\n        self.index = 0\n        self.disk = disk\n        self.jump()\n\n    def next(self):\n        ''' next song. '''\n        self.index = (self.index + 1) % len(self.disk)\n        self.jump()\n\n    def prev(self):\n        ''' prev song. '''\n        self.index = (self.index - 1) % len(self.disk)\n        self.jump()\n            \n    def jump(self):\n        ''' jump to the song. '''\n        self.lyrics = self.disk[self.index]\n\n    def sing_me_a_song(self):\n        for line in self.lyrics:\n            print(line)\n\n# construct a disk      \nsong1 =  [\"Happy birthday to you\",\n\"I don't want to get sued\",\n\"So I'll stop right there\"]           \n\nsong2 = [\"They rally around the family\",\n\"With pockets full of shells\"\n]\n\nsong3 = [\"Never mind I find\",\n\"Some one like you\"\n]\n\ndisk = [song1, song2, song3]\n\nmycd = Song(disk)\nmycd.sing_me_a_song()\n\nmycd.next()\nmycd.sing_me_a_song()\n\nmycd.next()\nmycd.sing_me_a_song()\n\nmycd.next()\nmycd.sing_me_a_song()\n\nmycd.prev()\nmycd.sing_me_a_song()\n\nmycd.prev()\nmycd.sing_me_a_song()\n\nmycd.prev()\nmycd.sing_me_a_song()\n\nmycd.prev()\nmycd.sing_me_a_song()"
  },
  {
    "path": "Python3/ex40.py",
    "content": "#!/usr/bin/env python3\n\n# ex40: Modules, CLasses, and Objects\n\nclass Song(object):\n    \n    def __init__(self,lyrics):\n        self.lyrics = lyrics\n    \n    def sing_me_a_song(self):\n        for line in self.lyrics:\n            print(line)\n\nhappy_bday = Song([\"Happy birthday to you\",\n                   \"I don't want to get sued\",\n                   \"So I'll stop right there\"])\n\nbulls_on_parade = Song([\"They rally around the family\",\n                        \"With pockets full of shells\"])\n\nhappy_bday.sing_me_a_song()\n\nbulls_on_parade.sing_me_a_song()"
  },
  {
    "path": "Python3/ex41.py",
    "content": "#!/usr/bin/env python3\n\n# ex41: Learning To Speak Object Oriented\n\nimport random\nfrom urllib.request import urlopen\nimport sys\n\nWORD_URL = \"http://learncodethehardway.org/words.txt\"\nWORDS = []\n\nPHRASES = {\n    \"class %%%(%%%):\":\n      \"Make a class named %%% that is-a %%%.\",\n    \"class %%%(object):\\n\\tdef __init__(self, ***)\" :\n      \"class %%% has-a __init__ that takes self and *** parameters.\",\n    \"class %%%(object):\\n\\tdef ***(self, @@@)\":\n      \"class %%% has-a function named *** that takes self and @@@ parameters.\",\n    \"*** = %%%()\":\n      \"Set *** to an instance of class %%%.\",\n    \"***.***(@@@)\":\n      \"From *** get the *** function, and call it with parameters self, @@@.\",\n    \"***.*** = '***'\":\n      \"From *** get the *** attribute and set it to '***'.\"\n}\n\n# do they want to drill phrases first\nPHRASE_FIRST = False\nif len(sys.argv) == 2 and sys.argv[1] == \"english\":\n    PHRASE_FIRST = True\n\n# load up the words from the website\nfor word in urlopen(WORD_URL).readlines():\n    WORDS.append(word.strip().decode(\"utf-8\"))\n\ndef convert(snippet, phrase):\n    class_names = [w.capitalize() for w in random.sample(WORDS, snippet.count(\"%%%\"))]\n    other_names = random.sample(WORDS, snippet.count(\"***\"))\n    results = []\n    param_names = []\n\n    for i in range(0, snippet.count(\"@@@\")):\n        param_count = random.randint(1,3)\n        param_names.append(', '.join(random.sample(WORDS, param_count)))\n\n    for sentence in snippet, phrase:\n        result = sentence[:]\n\n        # fake class names\n        for word in class_names:\n            result = result.replace(\"%%%\", word, 1)\n\n        # fake other names\n        for word in other_names:\n            result = result.replace(\"***\", word, 1)\n\n        # fake parameter lists\n        for word in param_names:\n            result = result.replace(\"@@@\", word, 1)\n\n        results.append(result)\n\n    return results\n\n# keep going until they hit CTRL-D\ntry:\n    while True:\n        snippets = list(PHRASES.keys())\n        random.shuffle(snippets)\n\n        for snippet in snippets:\n            phrase = PHRASES[snippet]\n            question, answer = convert(snippet, phrase)\n            if PHRASE_FIRST:\n                question, answer = answer, question\n\n            print(question)\n\n            input(\"> \")\n            print(\"ANSWER:  %s\\n\\n\" % answer)\nexcept EOFError:\n    print(\"\\nBye\")"
  },
  {
    "path": "Python3/ex42.py",
    "content": "#!/bin/python3\n\n# ex42: Is-A, Has-A, Objects, and Classes\n\n## Animal is-a object (yes, sort of confusing) look at the extra credit\nclass Animal(object):\n    pass\n\n## Dog is-a Animal\nclass Dog(Animal):\n\n    def __init__(self, name):\n        ## Dog has-a name\n        self.name = name\n\n## Cat is-a animal\nclass Cat(Animal):\n\n    def __init__(self, name):\n        ## Cat has-a name\n        self.name = name\n\n## Person is-a object\nclass Person(object):\n\n    def __init__(self, name):\n        ## Person has-a name\n        self.name = name\n\n        ## Person has-a pet of some kind\n        self.pet = None\n\n## Employee is-a person\nclass Employee(Person):\n\n    def __init__(self, name, salary):\n        ## run the __init__ method of a parent class reliably\n        self.__init__(name)\n        super().__init__(name)\n        ## Employee has-a salary\n        self.salary = salary\n\n## Fish is-a object\nclass Fish(object):\n    pass\n\n## Salmon is-a Fish\nclass Salmon(Fish):\n    pass\n\n## Halibut is-a fish\nclass Halibut(Fish):\n    pass\n\n## rover is-a Dog\nrover = Dog(\"Rover\")\n\n## satan is-a Cat\nsatan = Cat(\"Satan\")\n\n## mary is-a Person\nmary = Person(\"Mary\")\n\n## mary's pet is satan\nmary.pet = satan\n\n## frank is-a Employee, his salary is 120000\nfrank = Employee(\"Frank\", 120000)\n\n## frank's pet is rover\nfrank.pet = rover\n\n## flipper is-a Fish\nflipper = Fish()\n\n## crouse is-a Salmon\ncrouse = Salmon()\n\n## harry is-a Halibut\nharry = Halibut()\n\n"
  },
  {
    "path": "Python3/ex43.py",
    "content": "#!/bin/python3\n\n# ex43: Basic Object-Oriented Analysis and Design\n\n# Class Hierarchy\n# * Map\n#   - next_scene\n#   - opening_scene\n# * Engine\n#   - play\n# * Scene\n#   - enter\n#   * Death\n#   * Central Corridor\n#   * Laser Weapon Armory\n#   * The Bridge\n#   * Escape Pod\n# * Human\n#   - attack\n#   - defend\n#   * Hero\n#   * Monster\n\nfrom sys import exit\nfrom random import randint\nimport time\nimport math\n\nclass Engine(object):\n\n    def __init__(self, scene_map, hero):\n        self.scene_map = scene_map\n        self.hero = hero\n\n    def play(self):\n        current_scene = self.scene_map.opening_scene()\n\n        while True:\n            print(\"\\n--------\")\n            next_scene_name = current_scene.enter(self.hero)\n            current_scene = self.scene_map.next_scene(next_scene_name)\n\n\n\n\nclass Scene(object):\n\n    def enter(self):\n        print(\"This scene is not yet configured. Subclass it and implement enter().\")\n        exit(1)\n\nclass Death(Scene):\n\n    quips = [\n        \"You died.  You kinda suck at this.\",\n         \"Your mom would be proud...if she were smarter.\",\n         \"Such a luser.\",\n         \"I have a small puppy that's better at this.\"\n    ]\n\n    def enter(self, hero):\n        print(Death.quips[randint(0, len(self.quips)-1)])\n        exit(1)\n\nclass CentralCorridor(Scene):\n\n    def enter(self, hero):\n        print(\"The Gothons of Planet Percal #25 have invaded your ship and destroyed\")\n        print(\"your entire crew.  You are the last surviving member and your last\")\n        print(\"mission is to get the neutron destruct bomb from the Weapons Armory,\")\n        print(\"put it in the bridge, and blow the ship up after getting into an \")\n        print(\"escape pod.\")\n        print(\"\\n\")\n        print(\"You're running down the central corridor to the Weapons Armory when\")\n        print(\"a Gothon jumps out, red scaly skin, dark grimy teeth, and evil clown costume\")\n        print(\"flowing around his hate filled body.  He's blocking the door to the\")\n        print(\"Armory and about to pull a weapon to blast you.\")\n\n        action = input(\"> \")\n\n        if action == \"shoot!\":\n            print(\"Quick on the draw you yank out your blaster and fire it at the Gothon.\")\n            print(\"His clown costume is flowing and moving around his body, which throws\")\n            print(\"off your aim.  Your laser hits his costume but misses him entirely.  This\")\n            print(\"completely ruins his brand new costume his mother bought him, which\")\n            print(\"makes him fly into an insane rage and blast you repeatedly in the face until\")\n            print(\"you are dead.  Then he eats you.\")\n            return 'death'\n\n        elif action == \"dodge!\":\n            print(\"Like a world class boxer you dodge, weave, slip and slide right\")\n            print(\"as the Gothon's blaster cranks a laser past your head.\")\n            print(\"In the middle of your artful dodge your foot slips and you\")\n            print(\"bang your head on the metal wall and pass out.\")\n            print(\"You wake up shortly after only to die as the Gothon stomps on\")\n            print(\"your head and eats you.\")\n            return 'death'\n\n        elif action == \"tell a joke\":\n            print(\"Lucky for you they made you learn Gothon insults in the academy.\")\n            print(\"You tell the one Gothon joke you know:\")\n            print(\"Lbhe zbgure vf fb sng, jura fur fvgf nebhaq gur ubhfr, fur fvgf nebhaq gur ubhfr.\")\n            print(\"The Gothon stops, tries not to laugh, then busts out laughing and can't move.\")\n            print(\"While he's laughing you run up and shoot him square in the head\")\n            print(\"putting him down, then jump through the Weapon Armory door.\")\n            return 'laser_weapon_armory'\n\n        else:\n            print(\"DOES NOT COMPUTE!\")\n            return 'central_corridor'\n\nclass LaserWeaponArmory(Scene):\n\n    def enter(self, hero):\n        print(\"You do a dive roll into the Weapon Armory, crouch and scan the room\")\n        print(\"for more Gothons that might be hiding.  It's dead quiet, too quiet.\")\n        print(\"You stand up and run to the far side of the room and find the\")\n        print(\"neutron bomb in its container.  There's a keypad lock on the box\")\n        print(\"and you need the code to get the bomb out.  If you get the code\")\n        print(\"wrong 10 times then the lock closes forever and you can't\")\n        print(\"get the bomb.  The code is 3 digits.\")\n        code = \"%d%d%d\" % (randint(1,9), randint(1,9), randint(1,9))\n\n        print(code)\n\n        guesses = 0\n\n        while guesses < 10:\n            guess = input(\"[keypad]> \")\n            if guess == code:\n                break\n            print(\"BZZZZEDDD!\")\n            guesses += 1\n\n        if guess == code:\n            print(\"The container clicks open and the seal breaks, letting gas out.\")\n            print(\"You grab the neutron bomb and run as fast as you can to the\")\n            print(\"bridge where you must place it in the right spot.\")\n            return 'the_bridge'\n        else:\n            print(\"The lock buzzes one last time and then you hear a sickening\")\n            print(\"melting sound as the mechanism is fused together.\")\n            print(\"You decide to sit there, and finally the Gothons blow up the\")\n            print(\"ship from their ship and you die.\")\n            return 'death'\n\n\n\nclass TheBridge(Scene):\n\n    def enter(self, hero):\n        print(\"You burst onto the Bridge with the netron destruct bomb\")\n        print(\"under your arm and surprise 5 Gothons who are trying to\")\n        print(\"take control of the ship.  Each of them has an even uglier\")\n        print(\"clown costume than the last.  They haven't pulled their\")\n        print(\"weapons out yet, as they see the active bomb under your\")\n        print(\"arm and don't want to set it off.\")\n\n        action = input(\"> \")\n\n        if action == \"throw the bomb\":\n            print(\"In a panic you throw the bomb at the group of Gothons\")\n            print(\"and make a leap for the door.  Right as you drop it a\")\n            print(\"Gothon shoots you right in the back killing you.\")\n            print(\"As you die you see another Gothon frantically try to disarm\")\n            print(\"the bomb. You die knowing they will probably blow up when\")\n            print(\"it goes off.\")\n            return 'death'\n\n        elif action == \"slowly place the bomb\":\n            print(\"You point your blaster at the bomb under your arm\")\n            print(\"and the Gothons put their hands up and start to sweat.\")\n            print(\"You inch backward to the door, open it, and then carefully\")\n            print(\"place the bomb on the floor, pointing your blaster at it.\")\n            print(\"You then jump back through the door, punch the close button\")\n            print(\"and blast the lock so the Gothons can't get out.\")\n            print(\"Now that the bomb is placed you run to the escape pod to\")\n            print(\"get off this tin can.\")\n            return 'escape_pod'\n        else:\n            print(\"DOES NOT COMPUTE!\")\n            return \"the_bridge\"\n\n\nclass EscapePod(Scene):\n\n    def enter(self, hero):\n        print(\"You rush through the ship desperately trying to make it to\")\n        print(\"the escape pod before the whole ship explodes.  It seems like\")\n        print(\"hardly any Gothons are on the ship, so your run is clear of\")\n        print(\"interference.  You get to the chamber with the escape pods, and\")\n        print(\"now need to pick one to take.  Some of them could be damaged\")\n        print(\"but you don't have time to look.  There's 5 pods, which one\")\n        print(\"do you take?\")\n\n        good_pod = randint(1,5)\n        print(good_pod)\n        guess = input(\"[pod #]> \")\n\n\n        if int(guess) != good_pod:\n            print(\"You jump into pod %s and hit the eject button.\" % guess)\n            print(\"The pod escapes out into the void of space, then\")\n            print(\"implodes as the hull ruptures, crushing your body\")\n            print(\"into jam jelly.\")\n            return 'death'\n        else:\n            print(\"You jump into pod %s and hit the eject button.\" % guess)\n            print(\"The pod easily slides out into space heading to\")\n            print(\"the planet below.  As it flies to the planet, you look\")\n            print(\"back and see your ship implode then explode like a\")\n            print(\"bright star, taking out the Gothon ship at the same\")\n            print(\"time.  You won!\")\n\n            return 'final_fight'\n\nclass Win(Scene):\n    ''' Win '''\n\n    def enter(self, hero):\n\n        print('''\n        You Win! Good Job!\n        ''')\n\n        exit(0)\n\nclass Final(Scene):\n\n    ''' final fight '''\n\n    def enter(self, hero):\n\n        # initialize a monster\n        monster = Monster(\"Gothon\")\n\n        print(\"%s, You now came across the final boss %s! Let's fight!!!\" % (hero.name, monster.name))\n\n\n        a_combat = Combat()\n\n        next_stage = a_combat.combat(hero, monster)\n        return next_stage\n\nclass Combat(object):\n\n    def combat(self, hero, monster):\n\n        ''' combat between two roles '''\n\n        round = 1\n        while True:\n            print('='*30)\n            print('round %d' % round)\n            print('='*30)\n            print(\"Your HP: %d\" % hero.hp)\n            print(\"%s's HP: %d\" % (monster.name, monster.hp))\n            print('Which action do you want to take?')\n            print('-'*10)\n            print('1) attack - Attack the enemy')\n            print('2) defend - Defend from being attacked, also will recover a bit')\n\n            try:\n                action = int(input('> '))\n            except ValueError:\n                print(\"Please enter a number!!\")\n                continue\n\n            # defending should be done before attacking\n            if action == 2:\n                hero.defend()\n\n            # action of monster, 1/5 possibility it will defends\n            monster_action = randint(1, 6)\n            if monster_action == 5:\n                monster.defend()\n\n            if action == 1:\n                hero.attack(monster)\n            elif action == 2:\n                pass\n            else:\n                print(\"No such action!\")\n\n            if monster_action < 5:\n                monster.attack(hero)\n\n            # whether win or die\n            if hero.hp <= 0:\n                return 'death'\n\n            if monster.hp <= 0:\n                return 'win'\n\n            hero.rest()\n            monster.rest()\n\n            round += 1\n\nclass Map(object):\n\n    scenes = {\n        'central_corridor': CentralCorridor(),\n        'laser_weapon_armory': LaserWeaponArmory(),\n        'the_bridge': TheBridge(),\n        'escape_pod': EscapePod(),\n        'death': Death(),\n        'final_fight': Final(),\n        'win': Win()\n    }\n\n    def __init__(self, start_scene):\n        self.start_scene = start_scene\n\n    def next_scene(self, scene_name):\n        return Map.scenes.get(scene_name)\n\n    def opening_scene(self):\n        return self.next_scene(self.start_scene)\n\nclass Human(object):\n\n    ''' class for human '''\n    defending = 0\n\n    def __init__(self, name):\n        self.name = name\n\n    def attack(self, target):\n        ''' attack the target '''\n        percent = 0\n        time.sleep(1)\n        if target.defending == 1:\n            percent = float(self.power) / 10.0 + randint(0, 10)\n            target.hp = math.floor(target.hp - percent)\n        else:\n            percent = float(self.power) / 5.0 + randint(0, 10)\n            target.hp = math.floor(target.hp - percent)\n        print(\"%s attack %s. %s's HP decreased by %d points.\" % (self.name, target.name, target.name, percent))\n\n    def defend(self):\n        ''' be in the defending state. '''\n        self.defending = 1\n        print(\"%s is trying to defend.\" % self.name)\n\n    def rest(self):\n        ''' recover a bit after each round '''\n        if self.defending == 1:\n            percent = self.rate * 10 + randint(0, 10)\n        else:\n            percent = self.rate * 2 + randint(0, 10)\n        self.hp += percent\n        print(\"%s's HP increased by %d after rest.\" % (self.name, percent))\n        self.defending = 0\n\n\nclass Hero(Human):\n    ''' class for hero '''\n\n    hp = 1000\n    power = 200\n    rate = 5\n\nclass Monster(Human):\n    ''' class for monster '''\n    hp = 5000\n    power = 250\n    rate = 5\n\na_map = Map('central_corridor')\na_hero = Hero('Joe')\na_game = Engine(a_map, a_hero)\na_game.play()\n"
  },
  {
    "path": "Python3/ex44.py",
    "content": "#!/bin/python3\n\n# ex44: Inheritance vs. Composition\n\nclass Other(object):\n\n    def override(self):\n        print(\"OTHER override()\")\n\n    def implicit(self):\n        print(\"OTHER implicit()\")\n\n    def altered(self):\n        print(\"OTHER altered()\")\n\nclass Child(object):\n\n    def __init__(self):\n        self.other = Other()\n\n    def implicit(self):\n        self.other.implicit()\n\n    def override(self):\n        print(\"CHILD override()\")\n\n    def altered(self):\n        print(\"CHILD, BEFORE OTHER altered()\")\n        self.other.altered()\n        print(\"CHILD, AFTER OTHER altered()\")\n\nson = Child()\n\nson.implicit()\nson.override()\nson.altered()\n"
  },
  {
    "path": "Python3/ex46/skeleton/NAME/__init__.py",
    "content": ""
  },
  {
    "path": "Python3/ex46/skeleton/setup.py",
    "content": "try:\n    from setuptools import setup\nexcept ImportError:\n    from distutils.core import setup\n\nconfig = {\n    'description': 'My Project',\n    'author': 'Joseph Pan',\n    'url': 'URL to get it at.',\n    'download_url': 'Where to download it.',\n    'author_email': 'cs.wzpan@gmail.com',\n    'version': '0.1',\n    'install_requires': ['nose'],\n    'packages': ['NAME'],\n    'scripts': [],\n    'name': 'projectname'\n}\n\nsetup(**config)\n"
  },
  {
    "path": "Python3/ex46/skeleton/tests/NAME_test.py",
    "content": "from nose.tools import *\nimport NAME\n\ndef setup():\n    print(\"SETUP!\")\n\ndef teardown():\n    print(\"TEAR DOWN!\")\n\ndef test_basic():\n    print(\"I RAN!\")\n"
  },
  {
    "path": "Python3/ex46/skeleton/tests/__init__.py",
    "content": ""
  },
  {
    "path": "Python3/game/skeleton/README",
    "content": "A little python site\n\n1) For Linux/MacOSX user\n\nPlease execute\n\n```\nexport PYTHONPATH=$PYTHONPATH:.\npython2 bin/app.py\n```\n\nthen visit <http://localhost:8080> to browse the site!\n\n1) For Windows user\n\nPlease execute\n\n```\n$env:PYTHONPATH = \"$env:PYTHONPATH;.\"\npython2 bin/app.py\n```\n\nthen visit <http://localhost:8080> to browse the site!\n"
  },
  {
    "path": "Python3/game/skeleton/bin/MultipartPostHandler.py",
    "content": "#!/usr/bin/python\n\n####\n# 02/2006 Will Holcomb <wholcomb@gmail.com>\n# \n# This library is free software; you can redistribute it and/or\n# modify it under the terms of the GNU Lesser General Public\n# License as published by the Free Software Foundation; either\n# version 2.1 of the License, or (at your option) any later version.\n# \n# This library is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n# Lesser General Public License for more details.\n#\n# 7/26/07 Slightly modified by Brian Schneider  \n# in order to support unicode files ( multipart_encode function )\n\"\"\"\nUsage:\n  Enables the use of multipart/form-data for posting forms\n\nInspirations:\n  Upload files in python:\n    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306\n  urllib2_file:\n    Fabien Seisen: <fabien@seisen.org>\n\nExample:\n  import MultipartPostHandler, urllib2, cookielib\n\n  cookies = cookielib.CookieJar()\n  opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies),\n                                MultipartPostHandler.MultipartPostHandler)\n  params = { \"username\" : \"bob\", \"password\" : \"riviera\",\n             \"file\" : open(\"filename\", \"rb\") }\n  opener.open(\"http://wwww.bobsite.com/upload/\", params)\n\nFurther Example:\n  The main function of this file is a sample which downloads a page and\n  then uploads it to the W3C validator.\n\"\"\"\n\nimport urllib\nimport urllib2\nimport mimetools, mimetypes\nimport os, stat\nfrom cStringIO import StringIO\n\nclass Callable:\n    def __init__(self, anycallable):\n        self.__call__ = anycallable\n\n# Controls how sequences are uncoded. If true, elements may be given multiple values by\n#  assigning a sequence.\ndoseq = 1\n\nclass MultipartPostHandler(urllib2.BaseHandler):\n    handler_order = urllib2.HTTPHandler.handler_order - 10 # needs to run first\n\n    def http_request(self, request):\n        data = request.get_data()\n        if data is not None and type(data) != str:\n            v_files = []\n            v_vars = []\n            try:\n                 for(key, value) in data.items():\n                     if type(value) == file:\n                         v_files.append((key, value))\n                     else:\n                         v_vars.append((key, value))\n            except TypeError:\n                systype, value, traceback = sys.exc_info()\n                raise TypeError, \"not a valid non-string sequence or mapping object\", traceback\n\n            if len(v_files) == 0:\n                data = urllib.urlencode(v_vars, doseq)\n            else:\n                boundary, data = self.multipart_encode(v_vars, v_files)\n\n                contenttype = 'multipart/form-data; boundary=%s' % boundary\n                if(request.has_header('Content-Type')\n                   and request.get_header('Content-Type').find('multipart/form-data') != 0):\n                    print \"Replacing %s with %s\" % (request.get_header('content-type'), 'multipart/form-data')\n                request.add_unredirected_header('Content-Type', contenttype)\n\n            request.add_data(data)\n        \n        return request\n\n    def multipart_encode(vars, files, boundary = None, buf = None):\n        if boundary is None:\n            boundary = mimetools.choose_boundary()\n        if buf is None:\n            buf = StringIO()\n        for(key, value) in vars:\n            buf.write('--%s\\r\\n' % boundary)\n            buf.write('Content-Disposition: form-data; name=\"%s\"' % key)\n            buf.write('\\r\\n\\r\\n' + value + '\\r\\n')\n        for(key, fd) in files:\n            file_size = os.fstat(fd.fileno())[stat.ST_SIZE]\n            filename = fd.name.split('/')[-1]\n            contenttype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'\n            buf.write('--%s\\r\\n' % boundary)\n            buf.write('Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"\\r\\n' % (key, filename))\n            buf.write('Content-Type: %s\\r\\n' % contenttype)\n            # buffer += 'Content-Length: %s\\r\\n' % file_size\n            fd.seek(0)\n            buf.write('\\r\\n' + fd.read() + '\\r\\n')\n        buf.write('--' + boundary + '--\\r\\n\\r\\n')\n        buf = buf.getvalue()\n        return boundary, buf\n    multipart_encode = Callable(multipart_encode)\n\n    https_request = http_request\n\ndef main():\n    import tempfile, sys\n\n    validatorURL = \"http://validator.w3.org/check\"\n    opener = urllib2.build_opener(MultipartPostHandler)\n\n    def validateFile(url):\n        temp = tempfile.mkstemp(suffix=\".html\")\n        os.write(temp[0], opener.open(url).read())\n        params = { \"ss\" : \"0\",            # show source\n                   \"doctype\" : \"Inline\",\n                   \"uploaded_file\" : open(temp[1], \"rb\") }\n        print opener.open(validatorURL, params).read()\n        os.remove(temp[1])\n\n    if len(sys.argv[1:]) > 0:\n        for arg in sys.argv[1:]:\n            validateFile(arg)\n    else:\n        validateFile(\"http://www.google.com\")\n\nif __name__==\"__main__\":\n    main()\n"
  },
  {
    "path": "Python3/game/skeleton/bin/__init__.py",
    "content": ""
  },
  {
    "path": "Python3/game/skeleton/bin/app.py",
    "content": "import web, datetime, os\nfrom bin import map\n\nurls = (\n    '/', 'Index',\n    '/hello', 'SayHello',\n    '/image', 'Upload',\n    '/game', 'GameEngine',\n    '/entry', 'Entry'\n    )\n\napp = web.application(urls, locals())\n\n# little hack so that debug mode works with sessions\nif web.config.get('_session') is None:\n    store = web.session.DiskStore('sessions')\n    session = web.session.Session(app, store,\n                                  initializer={'room': None, 'name': 'Jedi'})\n    web.config._session = session\nelse:\n    session = web.config._session\n    \nrender = web.template.render('templates/', base=\"layout\")\n\nclass Index:\n    def GET(self):\n        return render.index()\n\n\nclass SayHello:\n    def GET(self):\n        return render.hello_form()\n    def POST(self):\n        form = web.input(name=\"Nobody\", greet=\"hello\")\n        if form.name == '':\n            form.name = \"Nobody\"\n        if form.greet == '':\n            form.greet = \"Hello\"\n        greeting = \"%s, %s\" % (form.greet, form.name)\n        return render.hello(greeting = greeting)\n\n\nclass Upload:\n    ''' using cgi to upload and show image '''\n    def GET(self):\n        return render.upload_form()\n    def POST(self):\n        form = web.input(myfile={})\n        # web.debug(form['myfile'].file.read())\n        # get the folder name\n        upload_time = datetime.datetime.now().strftime(\"%Y-%m-%d\")\n        # create the folder\n        folder = os.path.join('./static', upload_time)\n        if not os.access(folder, 1):\n            os.mkdir(folder)\n        # get the file name\n        filename = os.path.join(folder, form['myfile'].filename)\n        print(type(form['myfile']))\n        with open(filename, 'wb') as f:\n            f.write(form['myfile'].file.read())\n            f.close()\n        return render.show(filename = filename)\n\n\nclass count:\n    def GET(self):\n        session.count += 1\n        return str(session.count)\n\n\nclass reset:\n    def GET(self):\n        session.kill()\n        return \"\"\n\n\nclass Entry(object):\n    def GET(self):\n        return render.entry()\n    def POST(self):\n        form = web.input(name=\"Jedi\")\n        if form.name != '':\n            session.name = form.name\n        session.room = map.START\n        #session.description = session.room.description\n        web.seeother(\"/game\")\n    \n\nclass GameEngine(object):\n\n    def GET(self):\n        if session.room:\n            return render.show_room(room=session.room, name=session.name)\n        else:\n            # why is there here? do you need it?\n            return render.you_died()\n\n    def POST(self):\n        form = web.input(action=None)\n\n        # there is a bug here, can you fix it?\n        web.debug(session.room.name)\n        if session.room and session.room.name != \"The End\" and form.action:\n            session.room = session.room.go(form.action)\n\n        web.seeother(\"/game\")\n\nif __name__ == \"__main__\":\n    app.run()\n"
  },
  {
    "path": "Python3/game/skeleton/bin/map.py",
    "content": "from random import randint\n\nclass RoomError(Exception):\n    pass\n\nclass Room(object):\n\n    def __init__(self, name, description):\n        self.name = name\n        self.description = description\n        self.paths = {}\n\n    def go(self, direction):\n        return self.paths.get(direction, None)\n\n    def add_paths(self, paths):\n        self.paths.update(paths)\n\n\ncentral_corridor = Room(\"Central Corridor\",\n\"\"\"\nThe Gothons of Planet Percal #25 have invaded your ship and destroyed\nyour entire crew.  You are the last surviving member and your last\nmission is to get the neutron destruct bomb from the Weapons Armory,\nput it in the bridge, and blow the ship up after getting into an \nescape pod.\n\nYou're running down the central corridor to the Weapons Armory when\na Gothon jumps out, red scaly skin, dark grimy teeth, and evil clown costume\nflowing around his hate filled body.  He's blocking the door to the\nArmory and about to pull a weapon to blast you.\n\"\"\"                        \n                        )\n\n\nlaser_weapon_armory = Room(\"Laser Weapon Armory\",\n\"\"\"\nLucky for you they made you learn Gothon insults in the academy.\nYou tell the one Gothon joke you know:\nLbhe zbgure vf fb sng, jura fur fvgf nebhaq gur ubhfr, fur fvgf nebhaq gur ubhfr.\nThe Gothon stops, tries not to laugh, then busts out laughing and can't move.\nWhile he's laughing you run up and shoot him square in the head\nputting him down, then jump through the Weapon Armory door.\n\nYou do a dive roll into the Weapon Armory, crouch and scan the room\nfor more Gothons that might be hiding.  It's dead quiet, too quiet.\nYou stand up and run to the far side of the room and find the\nneutron bomb in its container.  There's a keypad lock on the box\nand you need the code to get the bomb out.  If you get the code\nwrong 10 times then the lock closes forever and you can't\nget the bomb.  The code is 3 digits.\n\"\"\"\n)\n\n\nthe_bridge = Room(\"The Bridge\",\n\"\"\"\nThe container clicks open and the seal breaks, letting gas out.\nYou grab the neutron bomb and run as fast as you can to the\nbridge where you must place it in the right spot.\n\nYou burst onto the Bridge with the netron destruct bomb\nunder your arm and surprise 5 Gothons who are trying to\ntake control of the ship.  Each of them has an even uglier\nclown costume than the last.  They haven't pulled their\nweapons out yet, as they see the active bomb under your\narm and don't want to set it off.\n\"\"\")\n\n\nescape_pod = Room(\"Escape Pod\",\n\"\"\"\nYou point your blaster at the bomb under your arm\nand the Gothons put their hands up and start to sweat.\nYou inch backward to the door, open it, and then carefully\nplace the bomb on the floor, pointing your blaster at it.\nYou then jump back through the door, punch the close button\nand blast the lock so the Gothons can't get out.\nNow that the bomb is placed you run to the escape pod to\nget off this tin can.\n\nYou rush through the ship desperately trying to make it to\nthe escape pod before the whole ship explodes.  It seems like\nhardly any Gothons are on the ship, so your run is clear of\ninterference.  You get to the chamber with the escape pods, and\nnow need to pick one to take.  Some of them could be damaged\nbut you don't have time to look.  There's 5 pods, which one\ndo you take?\n\"\"\")\n\n\nthe_end_winner = Room(\"The End\",\n\"\"\"\nYou jump into pod 2 and hit the eject button.\nThe pod easily slides out into space heading to\nthe planet below.  As it flies to the planet, you look\nback and see your ship implode then explode like a\nbright star, taking out the Gothon ship at the same\ntime.  You won!\n\"\"\")\n\n\nthe_end_loser = Room(\"The End\",\n\"\"\"\nYou jump into a random pod and hit the eject button.\nThe pod escapes out into the void of space, then\nimplodes as the hull ruptures, crushing your body\ninto jam jelly.\n\"\"\"\n)\n\n\n\ngeneric_death = Room(\"death\", \"You died\")\n\n\nescape_pod.add_paths({\n    '2': the_end_winner,\n    '*': the_end_loser\n    })\n\n\nthe_bridge.add_paths({\n    'throw the bomb': generic_death,\n    'slowly place the bomb': escape_pod\n})\n\n\nlaser_weapon_armory.add_paths({\n    '0132': the_bridge,\n    '*': generic_death\n})\n\n\ncentral_corridor.add_paths({\n    'shoot!': generic_death,\n    'dodge!': generic_death,\n    'tell a joke': laser_weapon_armory\n})\n\n\nSTART = central_corridor\n"
  },
  {
    "path": "Python3/game/skeleton/ex47/__init__.py",
    "content": ""
  },
  {
    "path": "Python3/game/skeleton/ex47/game.py",
    "content": "class Room(object):\n\n    def __init__(self, name, description):\n        self.name = name\n        self.description = description\n        self.paths = {}\n\n    def go(self, direction):\n        return self.paths.get(direction, None)\n\n    def add_paths(self, paths):\n        self.paths.update(paths)\n"
  },
  {
    "path": "Python3/game/skeleton/ex48/__init__.py",
    "content": ""
  },
  {
    "path": "Python3/game/skeleton/ex48/lexicon.py",
    "content": "import inflect\n\ndef scan(line):\n    ' scan a line and split into words '\n    words = line.split(' ')\n    # analyse words\n    result = []\n    # for each word, send it to the analyzer to analyse\n    for word in words:\n        # singular noun\n        p = inflect.engine()\n        # the inflect will singular 'princess' into 'princes' that I don't want   \n        if word != 'princess' and p.singular_noun(word):\n            word = p.singular_noun(word)\n\n        # Make sure the scanner handles user input in any capitalization and case.\n        type = analyse(word.lower())\n        result.append((type, word))\n    return result\n\n\ndef analyse(word):\n    ''' Input a word, return its type according to the rule.  '''\n    \n    rules = {\n        \"direction\": ['north', 'south', 'east', 'west', 'down', 'up', 'left', 'right', 'back'],\n        \"verb\": ['go', 'stop', 'kill', 'eat'],\n        \"stop\": ['the', 'in', 'of', 'from', 'at', 'it', 'to'],\n        \"noun\": ['door', 'bear', 'princess', 'carbinet']\n        }\n    \n    ''' analyse a word '''\n    if word.isdigit():\n        # if it's a number\n        return 'number'\n    for rule, rule_list in rules.items():\n        if word in rule_list:\n            # if it match any rule above\n            return rule\n    return 'error'\n"
  },
  {
    "path": "Python3/game/skeleton/ex49/__init__.py",
    "content": ""
  },
  {
    "path": "Python3/game/skeleton/ex49/parser.py",
    "content": "class ParserError(Exception):\n    pass\n\nclass Sentence(object):\n\n    def __init__(self, *args):\n        # remember we take ('noun','princess') tuples and convert them\n        argsnum = len(args)\n        if argsnum == 4:\n            self.subject = args[0][1]\n            self.verb = args[1][1]\n            self.num = int(args[2][1])\n            self.object = args[3][1]\n        elif argsnum == 3:\n            self.subject = args[0][1]\n            self.verb = args[1][1]\n            self.num = 1\n            self.object = args[2][1]\n        else:\n            raise TypeError(\"__init__() of class Sentence takes 4 or 5 arguments (%d given)\" % argsnum )\n    \ndef peek(word_list):\n    \n    if word_list:\n        word = word_list[0]\n        return word[0]\n    else:\n        return None\n\n\ndef match(word_list, expecting):\n    if word_list:\n        # notice the pop function here\n        word = word_list.pop(0)\n        if word[0] == expecting:\n            return word\n        else:\n            return None\n    else:\n        return None\n\n\ndef skip(word_list, word_type):\n    while peek(word_list) == word_type:\n        # remove words that belongs to word_type from word_list\n        match(word_list, word_type)\n\n\nclass Parser(object):\n\n    def parse_verb(self, word_list):\n        skip(word_list, 'stop')\n        skip(word_list, 'error')\n        skip(word_list, 'stop')\n        skip(word_list, 'error')\n\n        if peek(word_list) == 'verb':\n            return match(word_list, 'verb')\n        else:\n            raise ParserError(\"Expected a verb next.\")\n\n    def parse_num(self, word_list):\n        skip(word_list, 'stop')\n        skip(word_list, 'error')\n        skip(word_list, 'stop')\n        skip(word_list, 'error')\n\n        if peek(word_list) == 'number':\n            return match(word_list, 'number')\n        else:\n            return None\n\n\n    def parse_object(self, word_list):\n        skip(word_list, 'stop')\n        skip(word_list, 'error')\n        skip(word_list, 'stop')\n        skip(word_list, 'error')\n        next = peek(word_list)\n\n        if next == 'noun':\n            return match(word_list, 'noun')\n        if next == 'direction':\n            return match(word_list, 'direction')\n        else:\n            raise ParserError(\"Expected a noun or direction next.\")\n\n\n    def parse_subject(self, word_list, subj):\n        verb = self.parse_verb(word_list)\n        num = self.parse_num(word_list) # should be placed before object\n        obj = self.parse_object(word_list)\n        if num is not None:\n            return Sentence(subj, verb, num, obj)\n        else:\n            return Sentence(subj, verb, obj)\n\n\n    def parse_sentence(self, word_list):\n        skip(word_list, 'stop')\n        skip(word_list, 'error')\n        skip(word_list, 'stop')\n        skip(word_list, 'error')\n\n        start = peek(word_list)\n\n        if start == 'noun':\n            subj = match(word_list, 'noun')\n            return self.parse_subject(word_list, subj)\n        elif start == 'verb':\n            # assume the subject is the player then\n            return self.parse_subject(word_list, ('noun', 'player'))\n        else:\n            raise ParserError(\"Must start with subject, object, or verb not: %s\" % start)\n"
  },
  {
    "path": "Python3/game/skeleton/sessions/245c9a181ce6cc24de4e9c19d9f449d416ab940d",
    "content": "KGRwMQpTJ2lwJwpwMgpOc1Mncm9vbScKcDMKTnNTJ3Nlc3Npb25faWQnCnA0ClMnMjQ1YzlhMTgx\nY2U2Y2MyNGRlNGU5YzE5ZDlmNDQ5ZDQxNmFiOTQwZCcKcDUKc1MnbmFtZScKcDYKUydKZWRpJwpw\nNwpzLg==\n"
  },
  {
    "path": "Python3/game/skeleton/sessions/4d0905855a35a119c78d375479d0fe05b1778265",
    "content": "KGRwMQpTJ2lwJwpwMgpWMTI3LjAuMC4xCnAzCnNTJ3Jvb20nCnA0CmNjb3B5X3JlZwpfcmVjb25z\ndHJ1Y3RvcgpwNQooY2Jpbi5tYXAKUm9vbQpwNgpjX19idWlsdGluX18Kb2JqZWN0CnA3Ck50UnA4\nCihkcDkKUydwYXRocycKcDEwCihkcDExClMnc2hvb3QhJwpwMTIKZzUKKGc2Cmc3Ck50UnAxMwoo\nZHAxNApnMTAKKGRwMTUKc1MnbmFtZScKcDE2ClMnZGVhdGgnCnAxNwpzUydkZXNjcmlwdGlvbicK\ncDE4ClMnWW91IGRpZWQnCnAxOQpzYnNTJ2RvZGdlIScKcDIwCmcxMwpzUyd0ZWxsIGEgam9rZScK\ncDIxCmc1CihnNgpnNwpOdFJwMjIKKGRwMjMKZzEwCihkcDI0ClMnKicKZzEzCnNTJzAxMzInCnAy\nNQpnNQooZzYKZzcKTnRScDI2CihkcDI3CmcxMAooZHAyOApTJ3Rocm93IHRoZSBib21iJwpwMjkK\nZzEzCnNTJ3Nsb3dseSBwbGFjZSB0aGUgYm9tYicKcDMwCmc1CihnNgpnNwpOdFJwMzEKKGRwMzIK\nZzEwCihkcDMzClMnKicKZzUKKGc2Cmc3Ck50UnAzNAooZHAzNQpnMTAKKGRwMzYKc2cxNgpTJ1Ro\nZSBFbmQnCnAzNwpzZzE4ClMnXG5Zb3UganVtcCBpbnRvIGEgcmFuZG9tIHBvZCBhbmQgaGl0IHRo\nZSBlamVjdCBidXR0b24uXG5UaGUgcG9kIGVzY2FwZXMgb3V0IGludG8gdGhlIHZvaWQgb2Ygc3Bh\nY2UsIHRoZW5cbmltcGxvZGVzIGFzIHRoZSBodWxsIHJ1cHR1cmVzLCBjcnVzaGluZyB5b3VyIGJv\nZHlcbmludG8gamFtIGplbGx5LlxuJwpwMzgKc2JzUycyJwpnNQooZzYKZzcKTnRScDM5CihkcDQw\nCmcxMAooZHA0MQpzZzE2CmczNwpzZzE4ClMnXG5Zb3UganVtcCBpbnRvIHBvZCAyIGFuZCBoaXQg\ndGhlIGVqZWN0IGJ1dHRvbi5cblRoZSBwb2QgZWFzaWx5IHNsaWRlcyBvdXQgaW50byBzcGFjZSBo\nZWFkaW5nIHRvXG50aGUgcGxhbmV0IGJlbG93LiAgQXMgaXQgZmxpZXMgdG8gdGhlIHBsYW5ldCwg\neW91IGxvb2tcbmJhY2sgYW5kIHNlZSB5b3VyIHNoaXAgaW1wbG9kZSB0aGVuIGV4cGxvZGUgbGlr\nZSBhXG5icmlnaHQgc3RhciwgdGFraW5nIG91dCB0aGUgR290aG9uIHNoaXAgYXQgdGhlIHNhbWVc\nbnRpbWUuICBZb3Ugd29uIVxuJwpwNDIKc2Jzc2cxNgpTJ0VzY2FwZSBQb2QnCnA0MwpzZzE4ClMi\nXG5Zb3UgcG9pbnQgeW91ciBibGFzdGVyIGF0IHRoZSBib21iIHVuZGVyIHlvdXIgYXJtXG5hbmQg\ndGhlIEdvdGhvbnMgcHV0IHRoZWlyIGhhbmRzIHVwIGFuZCBzdGFydCB0byBzd2VhdC5cbllvdSBp\nbmNoIGJhY2t3YXJkIHRvIHRoZSBkb29yLCBvcGVuIGl0LCBhbmQgdGhlbiBjYXJlZnVsbHlcbnBs\nYWNlIHRoZSBib21iIG9uIHRoZSBmbG9vciwgcG9pbnRpbmcgeW91ciBibGFzdGVyIGF0IGl0Llxu\nWW91IHRoZW4ganVtcCBiYWNrIHRocm91Z2ggdGhlIGRvb3IsIHB1bmNoIHRoZSBjbG9zZSBidXR0\nb25cbmFuZCBibGFzdCB0aGUgbG9jayBzbyB0aGUgR290aG9ucyBjYW4ndCBnZXQgb3V0LlxuTm93\nIHRoYXQgdGhlIGJvbWIgaXMgcGxhY2VkIHlvdSBydW4gdG8gdGhlIGVzY2FwZSBwb2QgdG9cbmdl\ndCBvZmYgdGhpcyB0aW4gY2FuLlxuXG5Zb3UgcnVzaCB0aHJvdWdoIHRoZSBzaGlwIGRlc3BlcmF0\nZWx5IHRyeWluZyB0byBtYWtlIGl0IHRvXG50aGUgZXNjYXBlIHBvZCBiZWZvcmUgdGhlIHdob2xl\nIHNoaXAgZXhwbG9kZXMuICBJdCBzZWVtcyBsaWtlXG5oYXJkbHkgYW55IEdvdGhvbnMgYXJlIG9u\nIHRoZSBzaGlwLCBzbyB5b3VyIHJ1biBpcyBjbGVhciBvZlxuaW50ZXJmZXJlbmNlLiAgWW91IGdl\ndCB0byB0aGUgY2hhbWJlciB3aXRoIHRoZSBlc2NhcGUgcG9kcywgYW5kXG5ub3cgbmVlZCB0byBw\naWNrIG9uZSB0byB0YWtlLiAgU29tZSBvZiB0aGVtIGNvdWxkIGJlIGRhbWFnZWRcbmJ1dCB5b3Ug\nZG9uJ3QgaGF2ZSB0aW1lIHRvIGxvb2suICBUaGVyZSdzIDUgcG9kcywgd2hpY2ggb25lXG5kbyB5\nb3UgdGFrZT9cbiIKcDQ0CnNic3NnMTYKUydUaGUgQnJpZGdlJwpwNDUKc2cxOApTIlxuVGhlIGNv\nbnRhaW5lciBjbGlja3Mgb3BlbiBhbmQgdGhlIHNlYWwgYnJlYWtzLCBsZXR0aW5nIGdhcyBvdXQu\nXG5Zb3UgZ3JhYiB0aGUgbmV1dHJvbiBib21iIGFuZCBydW4gYXMgZmFzdCBhcyB5b3UgY2FuIHRv\nIHRoZVxuYnJpZGdlIHdoZXJlIHlvdSBtdXN0IHBsYWNlIGl0IGluIHRoZSByaWdodCBzcG90Llxu\nXG5Zb3UgYnVyc3Qgb250byB0aGUgQnJpZGdlIHdpdGggdGhlIG5ldHJvbiBkZXN0cnVjdCBib21i\nXG51bmRlciB5b3VyIGFybSBhbmQgc3VycHJpc2UgNSBHb3Rob25zIHdobyBhcmUgdHJ5aW5nIHRv\nXG50YWtlIGNvbnRyb2wgb2YgdGhlIHNoaXAuICBFYWNoIG9mIHRoZW0gaGFzIGFuIGV2ZW4gdWds\naWVyXG5jbG93biBjb3N0dW1lIHRoYW4gdGhlIGxhc3QuICBUaGV5IGhhdmVuJ3QgcHVsbGVkIHRo\nZWlyXG53ZWFwb25zIG91dCB5ZXQsIGFzIHRoZXkgc2VlIHRoZSBhY3RpdmUgYm9tYiB1bmRlciB5\nb3VyXG5hcm0gYW5kIGRvbid0IHdhbnQgdG8gc2V0IGl0IG9mZi5cbiIKcDQ2CnNic3NnMTYKUydM\nYXNlciBXZWFwb24gQXJtb3J5JwpwNDcKc2cxOApTIlxuTHVja3kgZm9yIHlvdSB0aGV5IG1hZGUg\neW91IGxlYXJuIEdvdGhvbiBpbnN1bHRzIGluIHRoZSBhY2FkZW15LlxuWW91IHRlbGwgdGhlIG9u\nZSBHb3Rob24gam9rZSB5b3Uga25vdzpcbkxiaGUgemJndXJlIHZmIGZiIHNuZywganVyYSBmdXIg\nZnZnZiBuZWJoYXEgZ3VyIHViaGZyLCBmdXIgZnZnZiBuZWJoYXEgZ3VyIHViaGZyLlxuVGhlIEdv\ndGhvbiBzdG9wcywgdHJpZXMgbm90IHRvIGxhdWdoLCB0aGVuIGJ1c3RzIG91dCBsYXVnaGluZyBh\nbmQgY2FuJ3QgbW92ZS5cbldoaWxlIGhlJ3MgbGF1Z2hpbmcgeW91IHJ1biB1cCBhbmQgc2hvb3Qg\naGltIHNxdWFyZSBpbiB0aGUgaGVhZFxucHV0dGluZyBoaW0gZG93biwgdGhlbiBqdW1wIHRocm91\nZ2ggdGhlIFdlYXBvbiBBcm1vcnkgZG9vci5cblxuWW91IGRvIGEgZGl2ZSByb2xsIGludG8gdGhl\nIFdlYXBvbiBBcm1vcnksIGNyb3VjaCBhbmQgc2NhbiB0aGUgcm9vbVxuZm9yIG1vcmUgR290aG9u\ncyB0aGF0IG1pZ2h0IGJlIGhpZGluZy4gIEl0J3MgZGVhZCBxdWlldCwgdG9vIHF1aWV0LlxuWW91\nIHN0YW5kIHVwIGFuZCBydW4gdG8gdGhlIGZhciBzaWRlIG9mIHRoZSByb29tIGFuZCBmaW5kIHRo\nZVxubmV1dHJvbiBib21iIGluIGl0cyBjb250YWluZXIuICBUaGVyZSdzIGEga2V5cGFkIGxvY2sg\nb24gdGhlIGJveFxuYW5kIHlvdSBuZWVkIHRoZSBjb2RlIHRvIGdldCB0aGUgYm9tYiBvdXQuICBJ\nZiB5b3UgZ2V0IHRoZSBjb2RlXG53cm9uZyAxMCB0aW1lcyB0aGVuIHRoZSBsb2NrIGNsb3NlcyBm\nb3JldmVyIGFuZCB5b3UgY2FuJ3RcbmdldCB0aGUgYm9tYi4gIFRoZSBjb2RlIGlzIDMgZGlnaXRz\nLlxuIgpwNDgKc2Jzc2cxNgpTJ0NlbnRyYWwgQ29ycmlkb3InCnA0OQpzZzE4ClMiXG5UaGUgR290\naG9ucyBvZiBQbGFuZXQgUGVyY2FsICMyNSBoYXZlIGludmFkZWQgeW91ciBzaGlwIGFuZCBkZXN0\ncm95ZWRcbnlvdXIgZW50aXJlIGNyZXcuICBZb3UgYXJlIHRoZSBsYXN0IHN1cnZpdmluZyBtZW1i\nZXIgYW5kIHlvdXIgbGFzdFxubWlzc2lvbiBpcyB0byBnZXQgdGhlIG5ldXRyb24gZGVzdHJ1Y3Qg\nYm9tYiBmcm9tIHRoZSBXZWFwb25zIEFybW9yeSxcbnB1dCBpdCBpbiB0aGUgYnJpZGdlLCBhbmQg\nYmxvdyB0aGUgc2hpcCB1cCBhZnRlciBnZXR0aW5nIGludG8gYW4gXG5lc2NhcGUgcG9kLlxuXG5Z\nb3UncmUgcnVubmluZyBkb3duIHRoZSBjZW50cmFsIGNvcnJpZG9yIHRvIHRoZSBXZWFwb25zIEFy\nbW9yeSB3aGVuXG5hIEdvdGhvbiBqdW1wcyBvdXQsIHJlZCBzY2FseSBza2luLCBkYXJrIGdyaW15\nIHRlZXRoLCBhbmQgZXZpbCBjbG93biBjb3N0dW1lXG5mbG93aW5nIGFyb3VuZCBoaXMgaGF0ZSBm\naWxsZWQgYm9keS4gIEhlJ3MgYmxvY2tpbmcgdGhlIGRvb3IgdG8gdGhlXG5Bcm1vcnkgYW5kIGFi\nb3V0IHRvIHB1bGwgYSB3ZWFwb24gdG8gYmxhc3QgeW91LlxuIgpwNTAKc2JzUydzZXNzaW9uX2lk\nJwpwNTEKUyc0ZDA5MDU4NTVhMzVhMTE5Yzc4ZDM3NTQ3OWQwZmUwNWIxNzc4MjY1JwpwNTIKc1Mn\nbmFtZScKcDUzClMnSmVkaScKcDU0CnMu\n"
  },
  {
    "path": "Python3/game/skeleton/sessions/58d0f5dc7cf6255fd5afc974df29abc610530f54",
    "content": "KGRwMQpTJ2lwJwpwMgpOc1Mncm9vbScKcDMKTnNTJ3Nlc3Npb25faWQnCnA0ClMnNThkMGY1ZGM3\nY2Y2MjU1ZmQ1YWZjOTc0ZGYyOWFiYzYxMDUzMGY1NCcKcDUKc1MnbmFtZScKcDYKUydKZWRpJwpw\nNwpzLg==\n"
  },
  {
    "path": "Python3/game/skeleton/sessions/6f14bd73122b385dea9a602e62982da36457a9c0",
    "content": "KGRwMQpTJ2lwJwpwMgpOc1Mncm9vbScKcDMKTnNTJ3Nlc3Npb25faWQnCnA0ClMnNmYxNGJkNzMx\nMjJiMzg1ZGVhOWE2MDJlNjI5ODJkYTM2NDU3YTljMCcKcDUKc1MnbmFtZScKcDYKUydKZWRpJwpw\nNwpzLg==\n"
  },
  {
    "path": "Python3/game/skeleton/sessions/8f517a270c46a0127095766db27a8f9541c464f9",
    "content": "KGRwMQpTJ2lwJwpwMgpOc1Mncm9vbScKcDMKTnNTJ3Nlc3Npb25faWQnCnA0ClMnOGY1MTdhMjcw\nYzQ2YTAxMjcwOTU3NjZkYjI3YThmOTU0MWM0NjRmOScKcDUKc1MnbmFtZScKcDYKUydKZWRpJwpw\nNwpzLg==\n"
  },
  {
    "path": "Python3/game/skeleton/sessions/f72f2c47cd5454a04ec03a630fe296ea257619eb",
    "content": "KGRwMQpTJ2lwJwpwMgpWMTI3LjAuMC4xCnAzCnNTJ3Jvb20nCnA0Ck5zUydzZXNzaW9uX2lkJwpw\nNQpTJ2Y3MmYyYzQ3Y2Q1NDU0YTA0ZWMwM2E2MzBmZTI5NmVhMjU3NjE5ZWInCnA2CnNTJ25hbWUn\nCnA3ClMnSmVkaScKcDgKcy4=\n"
  },
  {
    "path": "Python3/game/skeleton/setup.py",
    "content": "try:\n    from setuptools import setup\nexcept ImportError:\n    from distutils.core import setup\n\nconfig = {\n    'description': 'My Project',\n    'author': 'Joseph Pan',\n    'url': 'URL to get it at.',\n    'download_url': 'Where to download it.',\n    'author_email': 'cs.wzpan@gmail.com',\n    'version': '0.1',\n    'install_requires': ['nose'],\n    'packages': ['ex47'],\n    'scripts': [],\n    'name': 'projectname'\n}\n\nsetup(**config)\n"
  },
  {
    "path": "Python3/game/skeleton/static/css/marketing.css",
    "content": "* {\n    -webkit-box-sizing: border-box;\n    -moz-box-sizing: border-box;\n    box-sizing: border-box;\n}\n\nbody {\n    margin: 0 auto;\n    line-height: 1.7em;\n}\n\n.l-box {\n    padding: 1em;\n}\n\n.header {\n    margin: 0 0;\n}\n\n    .header .pure-menu {\n        padding: 0.5em;\n    }\n\n        .header .pure-menu li a:hover,\n        .header .pure-menu li a:focus {\n            background: none;\n            border: none;\n            color: #aaa;\n        }\n\nbody .primary-button {\n    background: #02a6eb;\n    color: #fff;\n}\n\n.splash {\n    margin: 2em auto 0;\n    padding: 3em 0.5em;\n    background: #eee;\n}\n    .splash .splash-head {\n        font-size: 300%;\n        margin: 0em 0;\n        line-height: 1.2em;\n    }\n    .splash .splash-subhead {\n        color: #999;\n        font-weight: 300;\n        line-height: 1.4em;\n    }\n    .splash .primary-button {\n        font-size: 150%;\n    }\n\n\n.content .content-subhead {\n    color: #999;\n    padding-bottom: 0.3em;\n    text-transform: uppercase;\n    margin: 0;\n    border-bottom: 2px solid #eee;\n    display: inline-block;\n}\n\n.content .content-ribbon {\n    margin: 3em;\n    border-bottom: 1px solid #eee;\n}\n\n.ribbon {\n    background: #eee;\n    text-align: center;\n    padding: 2em;\n    color: #999;\n}\n    .ribbon h2 {\n        display: inline;\n        font-weight: normal;\n    }\n\n.footer {\n    background: #111;\n    color: #666;\n    text-align: center;\n    padding: 1em;\n    font-size: 80%;\n}\n\n.pure-button-success,\n.pure-button-error,\n.pure-button-warning,\n.pure-button-secondary {\n  color: white;\n  border-radius: 4px;\n  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);\n}\n\n.pure-button-success {\n  background: rgb(28, 184, 65); /* this is a green */\n}\n\n.pure-button-error {\n  background: rgb(202, 60, 60); /* this is a maroon */\n}\n\n.pure-button-warning {\n  background: rgb(223, 117, 20); /* this is an orange */\n}\n\n.pure-button-secondary {\n  background: rgb(66, 184, 221); /* this is a light blue */\n}\n\n.content .content-quote {\n        font-family: \"Georgia\", serif;\n        color: #666;\n        font-style: italic;\n        line-height: 1.8em;\n        border-left: 5px solid #ddd;\n        padding-left: 1.5em;\n    }"
  },
  {
    "path": "Python3/game/skeleton/static/css/modal.css",
    "content": "/*!\n * Bootstrap v2.3.2\n *\n * Copyright 2012 Twitter, Inc\n * Licensed under the Apache License v2.0\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Designed and built with all the love in the world @twitter by @mdo and @fat.\n */\n\n.modal-backdrop {\n  position: fixed;\n  top: 0;\n  right: 0;\n  bottom: 0;\n  left: 0;\n  z-index: 1040;\n  background-color: #000000;\n}\n\n.modal-backdrop.fade {\n  opacity: 0;\n}\n\n.modal-backdrop,\n.modal-backdrop.fade.in {\n  opacity: 0.8;\n  filter: alpha(opacity=80);\n}\n\n.modal {\n  position: fixed;\n  top: 10%;\n  left: 50%;\n  z-index: 1050;\n  width: 560px;\n  margin-left: -280px;\n  background-color: #ffffff;\n  border: 1px solid #999;\n  border: 1px solid rgba(0, 0, 0, 0.3);\n  *border: 1px solid #999;\n  -webkit-border-radius: 6px;\n     -moz-border-radius: 6px;\n          border-radius: 6px;\n  outline: none;\n  -webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);\n     -moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);\n          box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);\n  -webkit-background-clip: padding-box;\n     -moz-background-clip: padding-box;\n          background-clip: padding-box;\n}\n\n.modal.fade {\n  top: -25%;\n  -webkit-transition: opacity 0.3s linear, top 0.3s ease-out;\n     -moz-transition: opacity 0.3s linear, top 0.3s ease-out;\n       -o-transition: opacity 0.3s linear, top 0.3s ease-out;\n          transition: opacity 0.3s linear, top 0.3s ease-out;\n}\n\n.modal.fade.in {\n  top: 10%;\n}\n\n.modal-header {\n  padding: 9px 15px;\n  border-bottom: 1px solid #eee;\n}\n\n.modal-header .close {\n  margin-top: 2px;\n}\n\n.modal-header h3 {\n  margin: 0;\n  line-height: 30px;\n}\n\n.modal-body {\n  position: relative;\n  max-height: 400px;\n  padding: 15px;\n  overflow-y: auto;\n}\n\n.modal-form {\n  margin-bottom: 0;\n}\n\n.modal-footer {\n  padding: 14px 15px 15px;\n  margin-bottom: 0;\n  text-align: right;\n  background-color: #f5f5f5;\n  border-top: 1px solid #ddd;\n  -webkit-border-radius: 0 0 6px 6px;\n     -moz-border-radius: 0 0 6px 6px;\n          border-radius: 0 0 6px 6px;\n  *zoom: 1;\n  -webkit-box-shadow: inset 0 1px 0 #ffffff;\n     -moz-box-shadow: inset 0 1px 0 #ffffff;\n          box-shadow: inset 0 1px 0 #ffffff;\n}\n\n.modal-footer:before,\n.modal-footer:after {\n  display: table;\n  line-height: 0;\n  content: \"\";\n}\n\n.modal-footer:after {\n  clear: both;\n}\n\n.modal-footer .btn + .btn {\n  margin-bottom: 0;\n  margin-left: 5px;\n}\n\n.modal-footer .btn-group .btn + .btn {\n  margin-left: -1px;\n}\n\n.modal-footer .btn-block + .btn-block {\n  margin-left: 0;\n}\n\n.hide {\n  display: none;\n}\n\n.show {\n  display: block;\n}\n\n.fade {\n  opacity: 0;\n  -webkit-transition: opacity 0.15s linear;\n     -moz-transition: opacity 0.15s linear;\n       -o-transition: opacity 0.15s linear;\n          transition: opacity 0.15s linear;\n}\n\n.fade.in {\n  opacity: 1;\n}\n"
  },
  {
    "path": "Python3/game/skeleton/static/css/pure-min.css",
    "content": "/*!\nPure v0.2.1\nCopyright 2013 Yahoo! Inc. All rights reserved.\nLicensed under the BSD License.\nhttps://github.com/yui/pure/blob/master/LICENSE.md\n*/\n/*!\nnormalize.css v1.1.2 | MIT License | git.io/normalize\nCopyright (c) Nicolas Gallagher and Jonathan Neal\n*/\n/*! normalize.css v1.1.2 | MIT License | git.io/normalize */article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none;height:0}[hidden]{display:none}html{font-size:100%;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}html,button,input,select,textarea{font-family:sans-serif}body{margin:0}a:focus{outline:thin dotted}a:active,a:hover{outline:0}h1{font-size:2em;margin:.67em 0}h2{font-size:1.5em;margin:.83em 0}h3{font-size:1.17em;margin:1em 0}h4{font-size:1em;margin:1.33em 0}h5{font-size:.83em;margin:1.67em 0}h6{font-size:.67em;margin:2.33em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}blockquote{margin:1em 40px}dfn{font-style:italic}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}mark{background:#ff0;color:#000}p,pre{margin:1em 0}code,kbd,pre,samp{font-family:monospace,serif;_font-family:'courier new',monospace;font-size:1em}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word}q{quotes:none}q:before,q:after{content:'';content:none}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}dl,menu,ol,ul{margin:1em 0}dd{margin:0 0 0 40px}menu,ol,ul{padding:0 0 0 40px}nav ul,nav ol{list-style:none;list-style-image:none}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}form{margin:0}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0;white-space:normal;*margin-left:-7px}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input{line-height:normal}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer;*overflow:visible}button[disabled],html input[disabled]{cursor:default}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0;*height:13px;*width:13px}input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}\n.pure-button{display:inline-block;*display:inline;zoom:1;line-height:normal;white-space:nowrap;vertical-align:baseline;text-align:center;cursor:pointer;-webkit-user-drag:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.pure-button::-moz-focus-inner{padding:0;border:0}.pure-button{font-size:100%;*font-size:90%;*overflow:visible;padding:.5em 1.5em;color:#444;color:rgba(0,0,0,.8);*color:#444;border:1px solid #999;border:0 rgba(0,0,0,0);background-color:#E6E6E6;text-decoration:none;border-radius:2px;-webkit-font-smoothing:antialiased;-webkit-transition:.1s linear -webkit-box-shadow;-moz-transition:.1s linear -moz-box-shadow;-ms-transition:.1s linear box-shadow;-o-transition:.1s linear box-shadow;transition:.1s linear box-shadow}.pure-button-hover,.pure-button:hover,.pure-button:focus{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#1a000000', GradientType=0);background-image:-webkit-gradient(linear,0 0,0 100%,from(transparent),color-stop(40%,rgba(0,0,0,.05)),to(rgba(0,0,0,.1)));background-image:-webkit-linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1));background-image:-moz-linear-gradient(top,rgba(0,0,0,.05) 0,rgba(0,0,0,.1));background-image:-ms-linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1));background-image:-o-linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1));background-image:linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1))}.pure-button:focus{outline:0}.pure-button-active,.pure-button:active{box-shadow:0 0 0 1px rgba(0,0,0,.15) inset,0 0 6px rgba(0,0,0,.2) inset}.pure-button[disabled],.pure-button-disabled,.pure-button-disabled:hover,.pure-button-disabled:focus,.pure-button-disabled:active{border:0;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);filter:alpha(opacity=40);-khtml-opacity:.4;-moz-opacity:.4;opacity:.4;cursor:not-allowed;box-shadow:none}.pure-button-hidden{display:none}.pure-button::-moz-focus-inner{padding:0;border:0}.pure-button-primary,.pure-button-selected,a.pure-button-primary,a.pure-button-selected{background-color:#0078e7;color:#fff}\n.pure-form{margin:0}.pure-form fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}.pure-form legend{border:0;padding:0;white-space:normal;*margin-left:-7px}.pure-form button,.pure-form input,.pure-form select,.pure-form textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}.pure-form button,.pure-form input{line-height:normal}.pure-form button,.pure-form input[type=button],.pure-form input[type=reset],.pure-form input[type=submit]{-webkit-appearance:button;cursor:pointer;*overflow:visible}.pure-form button[disabled],.pure-form input[disabled]{cursor:default}.pure-form input[type=checkbox],.pure-form input[type=radio]{box-sizing:border-box;padding:0;*height:13px;*width:13px}.pure-form input[type=search]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}.pure-form input[type=search]::-webkit-search-cancel-button,.pure-form input[type=search]::-webkit-search-decoration{-webkit-appearance:none}.pure-form button::-moz-focus-inner,.pure-form input::-moz-focus-inner{border:0;padding:0}.pure-form textarea{overflow:auto;vertical-align:top}.pure-form input[type=text],.pure-form input[type=password],.pure-form input[type=email],.pure-form input[type=url],.pure-form input[type=date],.pure-form input[type=month],.pure-form input[type=time],.pure-form input[type=datetime],.pure-form input[type=datetime-local],.pure-form input[type=week],.pure-form input[type=number],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=color],.pure-form select,.pure-form textarea{padding:.5em .6em;display:inline-block;border:1px solid #ccc;font-size:.8em;box-shadow:inset 0 1px 3px #ddd;border-radius:4px;-webkit-transition:.3s linear border;-moz-transition:.3s linear border;-ms-transition:.3s linear border;-o-transition:.3s linear border;transition:.3s linear border;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-font-smoothing:antialiased}.pure-form input[type=text]:focus,.pure-form input[type=password]:focus,.pure-form input[type=email]:focus,.pure-form input[type=url]:focus,.pure-form input[type=date]:focus,.pure-form input[type=month]:focus,.pure-form input[type=time]:focus,.pure-form input[type=datetime]:focus,.pure-form input[type=datetime-local]:focus,.pure-form input[type=week]:focus,.pure-form input[type=number]:focus,.pure-form input[type=search]:focus,.pure-form input[type=tel]:focus,.pure-form input[type=color]:focus,.pure-form select:focus,.pure-form textarea:focus{outline:0;outline:thin dotted \\9;border-color:#129FEA}.pure-form input[type=file]:focus,.pure-form input[type=radio]:focus,.pure-form input[type=checkbox]:focus{outline:thin dotted #333;outline:1px auto #129FEA}.pure-form .pure-checkbox,.pure-form .pure-radio{margin:.5em 0;display:block}.pure-form input[type=text][disabled],.pure-form input[type=password][disabled],.pure-form input[type=email][disabled],.pure-form input[type=url][disabled],.pure-form input[type=date][disabled],.pure-form input[type=month][disabled],.pure-form input[type=time][disabled],.pure-form input[type=datetime][disabled],.pure-form input[type=datetime-local][disabled],.pure-form input[type=week][disabled],.pure-form input[type=number][disabled],.pure-form input[type=search][disabled],.pure-form input[type=tel][disabled],.pure-form input[type=color][disabled],.pure-form select[disabled],.pure-form textarea[disabled]{cursor:not-allowed;background-color:#eaeded;color:#cad2d3}.pure-form input[readonly],.pure-form select[readonly],.pure-form textarea[readonly],.pure-form input[readonly]:focus,.pure-form select[readonly]:focus,.pure-form textarea[readonly]:focus{background:#eee;color:#777;border-color:#ccc}.pure-form input:focus:invalid,.pure-form textarea:focus:invalid,.pure-form select:focus:invalid{color:#b94a48;border:1px solid #ee5f5b}.pure-form input:focus:invalid:focus,.pure-form textarea:focus:invalid:focus,.pure-form select:focus:invalid:focus{border-color:#e9322d}.pure-form input[type=file]:focus:invalid:focus,.pure-form input[type=radio]:focus:invalid:focus,.pure-form input[type=checkbox]:focus:invalid:focus{outline-color:#e9322d}.pure-form select{border:1px solid #ccc;background-color:#fff}.pure-form select[multiple]{height:auto}.pure-form label{margin:.5em 0 .2em;font-size:90%}.pure-form fieldset{margin:0;padding:.35em 0 .75em;border:0}.pure-form legend{display:block;width:100%;padding:.3em 0;margin-bottom:.3em;font-size:125%;color:#333;border-bottom:1px solid #e5e5e5}.pure-form-stacked input[type=text],.pure-form-stacked input[type=password],.pure-form-stacked input[type=email],.pure-form-stacked input[type=url],.pure-form-stacked input[type=date],.pure-form-stacked input[type=month],.pure-form-stacked input[type=time],.pure-form-stacked input[type=datetime],.pure-form-stacked input[type=datetime-local],.pure-form-stacked input[type=week],.pure-form-stacked input[type=number],.pure-form-stacked input[type=search],.pure-form-stacked input[type=tel],.pure-form-stacked input[type=color],.pure-form-stacked select,.pure-form-stacked label,.pure-form-stacked textarea{display:block;margin:.25em 0}.pure-form-aligned input,.pure-form-aligned textarea,.pure-form-aligned select,.pure-form-aligned .pure-help-inline,.pure-form-message-inline{display:inline-block;*display:inline;*zoom:1;vertical-align:middle}.pure-form-aligned .pure-control-group{margin-bottom:.5em}.pure-form-aligned .pure-control-group label{text-align:right;display:inline-block;vertical-align:middle;width:10em;margin:0 1em 0 0}.pure-form-aligned .pure-controls{margin:1.5em 0 0 10em}.pure-form input.pure-input-rounded,.pure-form .pure-input-rounded{border-radius:2em;padding:.5em 1em}.pure-form .pure-group fieldset{margin-bottom:10px}.pure-form .pure-group input{display:block;padding:10px;margin:0;border-radius:0;position:relative;top:-1px}.pure-form .pure-group input:focus{z-index:2}.pure-form .pure-group input:first-child{top:1px;border-radius:4px 4px 0 0}.pure-form .pure-group input:last-child{top:-2px;border-radius:0 0 4px 4px}.pure-form .pure-group button{margin:.35em 0}.pure-form .pure-input-1{width:100%}.pure-form .pure-input-2-3{width:66%}.pure-form .pure-input-1-2{width:50%}.pure-form .pure-input-1-3{width:33%}.pure-form .pure-input-1-4{width:25%}.pure-form .pure-help-inline,.pure-form-message-inline{display:inline-block;padding-left:.3em;color:#666;vertical-align:middle;font-size:90%}.pure-form-message{display:block;color:#666;font-size:90%}@media only screen and (max-width :480px){.pure-form button[type=submit]{margin:.7em 0 0}.pure-form input[type=text],.pure-form input[type=password],.pure-form input[type=email],.pure-form input[type=url],.pure-form input[type=date],.pure-form input[type=month],.pure-form input[type=time],.pure-form input[type=datetime],.pure-form input[type=datetime-local],.pure-form input[type=week],.pure-form input[type=number],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=color],.pure-form label{margin-bottom:.3em;display:block}.pure-group input[type=text],.pure-group input[type=password],.pure-group input[type=email],.pure-group input[type=url],.pure-group input[type=date],.pure-group input[type=month],.pure-group input[type=time],.pure-group input[type=datetime],.pure-group input[type=datetime-local],.pure-group input[type=week],.pure-group input[type=number],.pure-group input[type=search],.pure-group input[type=tel],.pure-group input[type=color]{margin-bottom:0}.pure-form-aligned .pure-control-group label{margin-bottom:.3em;text-align:left;display:block;width:100%}.pure-form-aligned .pure-controls{margin:1.5em 0 0}.pure-form .pure-help-inline,.pure-form-message-inline,.pure-form-message{display:block;font-size:80%;padding:.2em 0 .8em}}\n.pure-g{letter-spacing:-.31em;*letter-spacing:normal;*word-spacing:-.43em;text-rendering:optimizespeed}.opera-only :-o-prefocus,.pure-g{word-spacing:-.43em}.pure-u{display:inline-block;*display:inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-1,.pure-u-1-2,.pure-u-1-3,.pure-u-2-3,.pure-u-1-4,.pure-u-3-4,.pure-u-1-5,.pure-u-2-5,.pure-u-3-5,.pure-u-4-5,.pure-u-1-6,.pure-u-5-6,.pure-u-1-8,.pure-u-3-8,.pure-u-5-8,.pure-u-7-8,.pure-u-1-12,.pure-u-5-12,.pure-u-7-12,.pure-u-11-12,.pure-u-1-24,.pure-u-5-24,.pure-u-7-24,.pure-u-11-24,.pure-u-13-24,.pure-u-17-24,.pure-u-19-24,.pure-u-23-24{display:inline-block;*display:inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-1{width:100%}.pure-u-1-2{width:50%}.pure-u-1-3{width:33.33333%}.pure-u-2-3{width:66.66666%}.pure-u-1-4{width:25%}.pure-u-3-4{width:75%}.pure-u-1-5{width:20%}.pure-u-2-5{width:40%}.pure-u-3-5{width:60%}.pure-u-4-5{width:80%}.pure-u-1-6{width:16.666%}.pure-u-5-6{width:83.33%}.pure-u-1-8{width:12.5%}.pure-u-3-8{width:37.5%}.pure-u-5-8{width:62.5%}.pure-u-7-8{width:87.5%}.pure-u-1-12{width:8.3333%}.pure-u-5-12{width:41.6666%}.pure-u-7-12{width:58.3333%}.pure-u-11-12{width:91.6666%}.pure-u-1-24{width:4.1666%}.pure-u-5-24{width:20.8333%}.pure-u-7-24{width:29.1666%}.pure-u-11-24{width:45.8333%}.pure-u-13-24{width:54.1666%}.pure-u-17-24{width:70.8333%}.pure-u-19-24{width:79.1666%}.pure-u-23-24{width:95.8333%}.pure-g-r{letter-spacing:-.31em;*letter-spacing:normal;*word-spacing:-.43em}.opera-only :-o-prefocus,.pure-g-r{word-spacing:-.43em}.pure-g-r img{max-width:100%}@media (min-width:980px){.pure-visible-phone{display:none}.pure-visible-tablet{display:none}.pure-hidden-desktop{display:none}}@media (max-width:480px){.pure-g-r>.pure-u,.pure-g-r>[class *=\"pure-u-\"]{width:100%}}@media (max-width:767px){.pure-g-r>.pure-u,.pure-g-r>[class *=\"pure-u-\"]{width:100%}.pure-hidden-phone{display:none}.pure-visible-desktop{display:none}}@media (min-width:768px) and (max-width:979px){.pure-hidden-tablet{display:none}.pure-visible-desktop{display:none}}\n.pure-menu ul{position:absolute;visibility:hidden}.pure-menu.pure-menu-open{visibility:visible;z-index:2;width:100%}.pure-menu ul{left:-10000px;list-style:none;margin:0;padding:0;top:-10000px;z-index:1}.pure-menu>ul{position:relative}.pure-menu-open>ul{left:0;top:0;visibility:visible}.pure-menu-open>ul:focus{outline:0}.pure-menu li{position:relative}.pure-menu a,.pure-menu .pure-menu-heading{display:block;color:inherit;line-height:1.5em;padding:5px 20px;text-decoration:none;white-space:nowrap}.pure-menu.pure-menu-horizontal>.pure-menu-heading{display:inline-block;*display:inline;zoom:1;margin:0;vertical-align:middle}.pure-menu.pure-menu-horizontal>ul{display:inline-block;*display:inline;zoom:1;vertical-align:middle;height:2.4em}.pure-menu li a{padding:5px 20px}.pure-menu-can-have-children>.pure-menu-label:after{content:'\\25B8';float:right;font-family:'Lucida Grande','Lucida Sans Unicode','DejaVu Sans',sans-serif;margin-right:-20px;margin-top:-1px}.pure-menu-can-have-children>.pure-menu-label{padding-right:30px}.pure-menu-separator{background-color:#dfdfdf;display:block;height:1px;font-size:0;margin:7px 2px;overflow:hidden}.pure-menu-hidden{display:none}.pure-menu-fixed{position:fixed;top:0;left:0;width:100%}.pure-menu-horizontal li{display:inline-block;*display:inline;zoom:1;vertical-align:middle}.pure-menu-horizontal li li{display:block}.pure-menu-horizontal>.pure-menu-children>.pure-menu-can-have-children>.pure-menu-label:after{content:\"\\25BE\"}.pure-menu-horizontal>.pure-menu-children>.pure-menu-can-have-children>.pure-menu-label{padding-right:30px}.pure-menu-horizontal li.pure-menu-separator{height:50%;width:1px;margin:0 7px}.pure-menu-horizontal li li.pure-menu-separator{height:1px;width:auto;margin:7px 2px}.pure-menu.pure-menu-open,.pure-menu.pure-menu-horizontal li .pure-menu-children{background:#fff;border:1px solid #b7b7b7}.pure-menu.pure-menu-horizontal,.pure-menu.pure-menu-horizontal .pure-menu-heading{border:0}.pure-menu a{border:1px solid transparent;border-left:0;border-right:0}.pure-menu a,.pure-menu .pure-menu-can-have-children>li:after{color:#777}.pure-menu .pure-menu-can-have-children>li:hover:after{color:#fff}.pure-menu .pure-menu-open{background:#dedede}.pure-menu li a:hover,.pure-menu li a:focus{background:#eee}.pure-menu li.pure-menu-disabled a:hover,.pure-menu li.pure-menu-disabled a:focus{background:#fff;color:#bfbfbf}.pure-menu .pure-menu-disabled>a{background-image:none;border-color:transparent;cursor:default}.pure-menu .pure-menu-disabled>a,.pure-menu .pure-menu-can-have-children.pure-menu-disabled>a:after{color:#bfbfbf}.pure-menu .pure-menu-heading{color:#565d64;text-transform:uppercase;font-size:90%;margin-top:.5em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#dfdfdf}.pure-menu .pure-menu-selected a{color:#000}.pure-menu.pure-menu-open.pure-menu-fixed{border:0;border-bottom:1px solid #b7b7b7}.pure-paginator{letter-spacing:-.31em;*letter-spacing:normal;*word-spacing:-.43em;text-rendering:optimizespeed;list-style:none;margin:0;padding:0}.opera-only :-o-prefocus,.pure-paginator{word-spacing:-.43em}.pure-paginator li{display:inline-block;*display:inline;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-paginator .pure-button{border-radius:0;padding:.8em 1.4em;vertical-align:top;height:1.1em}.pure-paginator .pure-button:focus,.pure-paginator .pure-button:active{outline-style:none}.pure-paginator .prev,.pure-paginator .next{color:#C0C1C3;text-shadow:0 -1px 0 rgba(0,0,0,.45)}.pure-paginator .prev{border-radius:2px 0 0 2px}.pure-paginator .next{border-radius:0 2px 2px 0}@media (max-width:480px){.pure-menu-horizontal{width:100%}.pure-menu-children li{display:block;border-bottom:1px solid #000}}\n.pure-table{border-collapse:collapse;border-spacing:0;empty-cells:show;border:1px solid #cbcbcb}.pure-table caption{color:#000;font:italic 85%/1 arial,sans-serif;padding:1em 0;text-align:center}.pure-table td,.pure-table th{border-left:1px solid #cbcbcb;border-width:0 0 0 1px;font-size:inherit;margin:0;overflow:visible;padding:6px 12px}.pure-table td:first-child,.pure-table th:first-child{border-left-width:0}.pure-table thead{background:#e0e0e0;color:#000;text-align:left;vertical-align:bottom}.pure-table td{background-color:transparent}.pure-table-odd td{background-color:#f2f2f2}.pure-table-striped tr:nth-child(2n-1) td{background-color:#f2f2f2}.pure-table-bordered td{border-bottom:1px solid #cbcbcb}.pure-table-bordered tbody>tr:last-child td,.pure-table-horizontal tbody>tr:last-child td{border-bottom-width:0}.pure-table-horizontal td,.pure-table-horizontal th{border-width:0 0 1px;border-bottom:1px solid #cbcbcb}.pure-table-horizontal tbody>tr:last-child td{border-bottom-width:0}"
  },
  {
    "path": "Python3/game/skeleton/static/js/modal.js",
    "content": "/* ========================================================================\n * Bootstrap: modal.js v3.0.0\n * http://twbs.github.com/bootstrap/javascript.html#modals\n * ========================================================================\n * Copyright 2012 Twitter, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n * ======================================================================== */\n\n\n+function ($) { \"use strict\";\n\n  // MODAL CLASS DEFINITION\n  // ======================\n\n  var Modal = function (element, options) {\n    this.options   = options\n    this.$element  = $(element)\n    this.$backdrop =\n    this.isShown   = null\n\n    if (this.options.remote) this.$element.load(this.options.remote)\n  }\n\n  Modal.DEFAULTS = {\n      backdrop: true\n    , keyboard: true\n    , show: true\n  }\n\n  Modal.prototype.toggle = function (_relatedTarget) {\n    return this[!this.isShown ? 'show' : 'hide'](_relatedTarget)\n  }\n\n  Modal.prototype.show = function (_relatedTarget) {\n    var that = this\n    var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })\n\n    this.$element.trigger(e)\n\n    if (this.isShown || e.isDefaultPrevented()) return\n\n    this.isShown = true\n\n    this.escape()\n\n    this.$element.on('click.dismiss.modal', '[data-dismiss=\"modal\"]', $.proxy(this.hide, this))\n\n    this.backdrop(function () {\n      var transition = $.support.transition && that.$element.hasClass('fade')\n\n      if (!that.$element.parent().length) {\n        that.$element.appendTo(document.body) // don't move modals dom position\n      }\n\n      that.$element.show()\n\n      if (transition) {\n        that.$element[0].offsetWidth // force reflow\n      }\n\n      that.$element\n        .addClass('in')\n        .attr('aria-hidden', false)\n\n      that.enforceFocus()\n\n      var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })\n\n      transition ?\n        that.$element.find('.modal-dialog') // wait for modal to slide in\n          .one($.support.transition.end, function () {\n            that.$element.focus().trigger(e)\n          })\n          .emulateTransitionEnd(300) :\n        that.$element.focus().trigger(e)\n    })\n  }\n\n  Modal.prototype.hide = function (e) {\n    if (e) e.preventDefault()\n\n    e = $.Event('hide.bs.modal')\n\n    this.$element.trigger(e)\n\n    if (!this.isShown || e.isDefaultPrevented()) return\n\n    this.isShown = false\n\n    this.escape()\n\n    $(document).off('focusin.bs.modal')\n\n    this.$element\n      .removeClass('in')\n      .attr('aria-hidden', true)\n      .off('click.dismiss.modal')\n\n    $.support.transition && this.$element.hasClass('fade') ?\n      this.$element\n        .one($.support.transition.end, $.proxy(this.hideModal, this))\n        .emulateTransitionEnd(300) :\n      this.hideModal()\n  }\n\n  Modal.prototype.enforceFocus = function () {\n    $(document)\n      .off('focusin.bs.modal') // guard against infinite focus loop\n      .on('focusin.bs.modal', $.proxy(function (e) {\n        if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {\n          this.$element.focus()\n        }\n      }, this))\n  }\n\n  Modal.prototype.escape = function () {\n    if (this.isShown && this.options.keyboard) {\n      this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {\n        e.which == 27 && this.hide()\n      }, this))\n    } else if (!this.isShown) {\n      this.$element.off('keyup.dismiss.bs.modal')\n    }\n  }\n\n  Modal.prototype.hideModal = function () {\n    var that = this\n    this.$element.hide()\n    this.backdrop(function () {\n      that.removeBackdrop()\n      that.$element.trigger('hidden.bs.modal')\n    })\n  }\n\n  Modal.prototype.removeBackdrop = function () {\n    this.$backdrop && this.$backdrop.remove()\n    this.$backdrop = null\n  }\n\n  Modal.prototype.backdrop = function (callback) {\n    var that    = this\n    var animate = this.$element.hasClass('fade') ? 'fade' : ''\n\n    if (this.isShown && this.options.backdrop) {\n      var doAnimate = $.support.transition && animate\n\n      this.$backdrop = $('<div class=\"modal-backdrop ' + animate + '\" />')\n        .appendTo(document.body)\n\n      this.$element.on('click.dismiss.modal', $.proxy(function (e) {\n        if (e.target !== e.currentTarget) return\n        this.options.backdrop == 'static'\n          ? this.$element[0].focus.call(this.$element[0])\n          : this.hide.call(this)\n      }, this))\n\n      if (doAnimate) this.$backdrop[0].offsetWidth // force reflow\n\n      this.$backdrop.addClass('in')\n\n      if (!callback) return\n\n      doAnimate ?\n        this.$backdrop\n          .one($.support.transition.end, callback)\n          .emulateTransitionEnd(150) :\n        callback()\n\n    } else if (!this.isShown && this.$backdrop) {\n      this.$backdrop.removeClass('in')\n\n      $.support.transition && this.$element.hasClass('fade')?\n        this.$backdrop\n          .one($.support.transition.end, callback)\n          .emulateTransitionEnd(150) :\n        callback()\n\n    } else if (callback) {\n      callback()\n    }\n  }\n\n\n  // MODAL PLUGIN DEFINITION\n  // =======================\n\n  var old = $.fn.modal\n\n  $.fn.modal = function (option, _relatedTarget) {\n    return this.each(function () {\n      var $this   = $(this)\n      var data    = $this.data('bs.modal')\n      var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)\n\n      if (!data) $this.data('bs.modal', (data = new Modal(this, options)))\n      if (typeof option == 'string') data[option](_relatedTarget)\n      else if (options.show) data.show(_relatedTarget)\n    })\n  }\n\n  $.fn.modal.Constructor = Modal\n\n\n  // MODAL NO CONFLICT\n  // =================\n\n  $.fn.modal.noConflict = function () {\n    $.fn.modal = old\n    return this\n  }\n\n\n  // MODAL DATA-API\n  // ==============\n\n  $(document).on('click.bs.modal.data-api', '[data-toggle=\"modal\"]', function (e) {\n    var $this   = $(this)\n    var href    = $this.attr('href')\n    var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\\s]+$)/, ''))) //strip for ie7\n    var option  = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())\n\n    e.preventDefault()\n\n    $target\n      .modal(option, this)\n      .one('hide', function () {\n        $this.is(':visible') && $this.focus()\n      })\n  })\n\n  $(document)\n    .on('show.bs.modal',  '.modal', function () { $(document.body).addClass('modal-open') })\n    .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })\n\n}(window.jQuery);\n"
  },
  {
    "path": "Python3/game/skeleton/static/js/validate.js",
    "content": "function validate_file(field)\n{\n    with (field)\n    {\n        if (value==null||value==\"\"){\n            $('#myModal').modal();\n            return false\n        }\n        else {return true}\n    }\n}\n\n\nfunction validate_form(thisform)\n{\n    with (thisform)\n    {\n        if (validate_file(myfile)==false){\n            myfile.focus();\n            return false\n        }\n    }\n}\n"
  },
  {
    "path": "Python3/game/skeleton/templates/entry.html",
    "content": "<h1>Fill Out This Form</h1>\n\n<form method=\"POST\" action=\"/entry\">\n  <div class=\"pure-form\">\n    <fieldset>\n      <legend>Enter the hero's name</legend>\n      <input type=\"text\" placeholder=\"Jedi\" name=\"name\" />\n    <input class=\"pure-button pure-button-primary\" type=\"submit\"/>\n    </fieldset>\n  </div>\n</form>\n"
  },
  {
    "path": "Python3/game/skeleton/templates/foo.html",
    "content": "$def with (word)\n\n<html>\n  <head>\n    <title>Yet another template page</title>\n  </head>\n\n<body>\n   $if word:\n       <h1>$word</h1>\n   $else:\n       <em>A blank page.</em>\n</body>\n</html>\n"
  },
  {
    "path": "Python3/game/skeleton/templates/hello.html",
    "content": "$def with (greeting)\n\n$if greeting:\n    <h2>\n        I just wanted to say <em class=\"text-success\">$greeting</em>.\n    </h2>\n$else:\n    <p>\n        <em>Hello</em>, world!\n    </p>\n\n<p>\n<button type=\"button\" class=\"pure-button pure-button-primary\" onclick=\"window.open('/')\">home</button>\n</p>\n"
  },
  {
    "path": "Python3/game/skeleton/templates/hello_form.html",
    "content": "<h1>Fill Out This Form</h1>\n\n<form method=\"POST\" action=\"/hello\">\n  <div class=\"pure-form\">\n    <fieldset>\n      <legend>A Greeting App</legend>\n      <input type=\"text\" placeholder=\"greeting word\" name=\"greet\" />\n      <input type=\"text\" placeholder=\"your name\" name=\"name\" />\n    <input class=\"pure-button pure-button-primary\" type=\"submit\"/>\n    </fieldset>\n  </div>\n</form>\n"
  },
  {
    "path": "Python3/game/skeleton/templates/index.html",
    "content": "<div align=\"center\">\n<h1>\n  This is the homepage\n</h1>\n  <h3>Type a greeting words as well as your name, you will see a greeting from me!</h3>\n  <h3>If you upload a photo, I will display it for you!<h3>\n</div>\n"
  },
  {
    "path": "Python3/game/skeleton/templates/layout.html",
    "content": "$def with (content)\n\n<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <!-- Bootstrap -->\n    <!--<link href=\"./static/css/bootstrap.css\" rel=\"stylesheet\" media=\"screen\">-->\n    <link href=\"./static/css/pure-min.css\" rel=\"stylesheet\">\n    <link href=\"./static/css/modal.css\" rel=\"stylesheet\">\n    <link href=\"./static/css/marketing.css\" rel=\"stylesheet\">\n    <script src=\"/static/js/validate.js\"></script>\n\n    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->\n    <script src=\"//code.jquery.com/jquery.js\"></script>\n    \n    <script src=\"./static/js/modal.js\"></script>\n\n    <title>Gothons From Planet Percal #25</title>\n  </head>\n\n  <body>\n    <div class=\"content\">\n      <div class=\"header\">\n        <div class=\"pure-menu pure-menu-open pure-menu-fixed pure-menu-horizontal\">\n          <a href=\"/\" class=\"pure-menu-heading\">A Python Site</a>\n          <ul>\n            <li><a href=\"/\">Home</a></li>\n            <li><a href=\"/hello\">Greeting</a></li>\n            <li><a href=\"/image\">Image</a></li>\n            <li><a href=\"/entry\">Game</a></li>\n          </ul>\n        </div>\n      </div>\n\n      <div class=\"splash\">\n        <div class=\"pure-g-r\">\n          <div class=\"pure-u-2-3\">\n            <div class=\"l-box splash-text\">\n              <h1 class=\"splash-head\">\n                A Python Site\n              </h1>\n              <h2 class=\"splash-subhead\">\n                Click the navbar to browse my site!\n              </h2>\n            </div>\n          </div>\n        </div>\n      </div>\n\n      <div class=\"content\">\n        <div class=\"content-ribbon\">\n          <div class=\"pure-u-1-5\">\n          </div>\n          <div class=\"pure-u-3-5\">\n            $:content\n          </div>\n          <div class=\"pure-u-1-5\">\n          </div>\n        </div>\n      </div>\n\n      <div class=\"footer\">\n        &copy; Joseph Pan 2013.\n      </div>\n    </div>\n\n    \n  </body>\n</html>\n"
  },
  {
    "path": "Python3/game/skeleton/templates/show.html",
    "content": "$def with (filename)\n<h1>\n  Here's the image you just uploaded.\n</h1>\n<div align=\"center\">\n  <img src=\"$filename\" class=\"img-rounded\"></img>\n</div>\n"
  },
  {
    "path": "Python3/game/skeleton/templates/show_room.html",
    "content": "$def with (room, name)\n\n<h1> $room.name </h1>\n\n<blockquote class=\"content-quote\">\n$room.description\n</blockquote>\n\n$if room.name == \"death\":\n    <p><a href=\"/\">Play Again?</a></p>\n$else:\n    <h1>Action</h1>\n    <form action=\"/game\" method=\"POST\">\n      <div class=\"pure-form\">\n        <fieldset>\n          <legend>$name, please type your action on what to do:</legend>\n          <input type=\"text\" name=\"action\"/>\n          <input class=\"pure-button pure-button-primary\"  type=\"submit\"/>\n        </fieldset>\n      </div>\n    </form>\n\n"
  },
  {
    "path": "Python3/game/skeleton/templates/upload_form.html",
    "content": "<h1>Upload An Image</h1>\n\n<div class=\"modal fade\" id=\"myModal\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\">\n  <div class=\"modal-dialog\">\n    <div class=\"modal-content\">\n      <div class=\"modal-header\">\n        <button type=\"button\" class=\"close pure-button-error\" data-dismiss=\"modal\" aria-hidden=\"true\">&times;</button>\n      </div>\n      <div class=\"modal-body\">\n        <p>You haven't choose a file. Please do that so that I can show you the magic!</p>\n      </div>\n      <div class=\"modal-footer\">\n        <button type=\"button\" class=\"pure-button pure-button-secondary\" data-dismiss=\"modal\">Close</button>\n      </div>\n    </div><!-- /.modal-content -->\n  </div><!-- /.modal-dialog -->\n</div><!-- /.modal -->\n\n<form method=\"POST\" action=\"/image\" onsubmit=\"return validate_form(this)\" enctype=\"multipart/form-data\">\n  <div class=\"pure-form\">\n    <fieldset>\n      <legend>Select a image and upload.</legend>\n      <input type=\"file\" name=\"myfile\">\n    </fieldset>\n  </div>\n  <input class=\"pure-button pure-button-primary\" type=\"submit\"/>\n</form> \n"
  },
  {
    "path": "Python3/game/skeleton/templates/you_died.html",
    "content": "<h1>You Died!</h1>\n\n<p>Looks like you bit the dust.</p>\n<button type=\"button\" class=\"pure-button pure-button-primary\" onclick=\"window.open('/entry')\">Play Again</button>\n"
  },
  {
    "path": "Python3/game/skeleton/test/__init__.py",
    "content": ""
  },
  {
    "path": "Python3/game/skeleton/test/app_test.py",
    "content": "from nose.tools import *\nfrom bin.app import app\nfrom test.tools import assert_response\nimport os\n\ndef test_Index():\n    # check that we get a 404 on the / URL\n    resp = app.request(\"/\")\n    assert_response(resp)\n\n\ndef test_SayHello():\n    # test our first GET request to /hello\n    resp = app.request(\"/hello\")\n    assert_response(resp)\n\n    # make sure default values work for the form\n    resp = app.request(\"/hello\", method=\"POST\")\n    assert_response(resp, contains=\"Nobody\")\n\n    # test that we get expected values\n    data = {'name': 'Zed', 'greet': 'Hola'}\n    resp = app.request(\"/hello\", method=\"POST\", data=data)\n    assert_response(resp, contains=\"Zed\")\n\n\nclass MyFile:\n    def __init__(self, filename, ):\n        self.filename = filename\n"
  },
  {
    "path": "Python3/game/skeleton/test/game_test.py",
    "content": "from nose.tools import *\nfrom ex47.game import Room\n\ndef test_room():\n    gold = Room(\"GoldRoom\",\n                \"\"\" This room has gold in it you can grab. There's a \\\n    door to the north.\"\"\"\n                )\n    assert_equal(gold.name, \"GoldRoom\")\n    assert_equal(gold.paths, {})\n\ndef test_room_paths():\n    center = Room(\"Center\", \"Test room in the center.\")\n    north = Room(\"North\", \"Test room in the north.\")\n    south = Room(\"South\", \"Test room in the south.\")\n\n    center.add_paths({'north': north, 'south': south})\n    assert_equal(center.go('north'), north)\n    assert_equal(center.go('south'), south)\n    \ndef test_map():\n    start = Room(\"Start\", \"You can go west and down a hole.\")\n    west = Room(\"Trees\", \"There are trees here, you can go east.\")\n    down = Room(\"Dungeon\", \"It's dark down here, you can go up.\")\n\n    start.add_paths({'west': west, 'down': down})\n    west.add_paths({'east': start})\n    down.add_paths({'up': start})\n\n    assert_equal(start.go('west'), west)\n    assert_equal(start.go('west').go('east'), start)\n    assert_equal(start.go('down').go('up'), start)\n"
  },
  {
    "path": "Python3/game/skeleton/test/lexicon_test.py",
    "content": "from nose.tools import *\nfrom ex48 import lexicon\n\n\ndef text_directions():\n    assert_equal(lexicon.scan(\"north\"), [('direction', 'north')])\n    result = lexicon.scan(\"north South EAST west dOwn up left right back\")\n    assert_equal(result, [('direction', 'north'),\n                          ('direction', 'South'),\n                          ('direction', 'EAST'),\n                          ('direction', 'west'),\n                          ('direction', 'dOwn'),\n                          ('direction', 'up'),\n                          ('direction', 'left'),\n                          ('direction', 'right'),\n                          ('direction', 'back')\n                          ])\n\n\ndef test_verbs():\n    assert_equal(lexicon.scan(\"go\"), [('verb', 'go')])\n    result = lexicon.scan(\"go KILL eat stop\")\n    assert_equal(result, [('verb', 'go'),\n                          ('verb', 'KILL'),\n                          ('verb', 'eat'),\n                          ('verb', 'stop')\n                          ])\n\n\ndef test_stops():\n    assert_equal(lexicon.scan(\"the\"), [('stop', 'the')])\n    result = lexicon.scan(\"the in of FROM at it\")\n    assert_equal(result, [('stop', 'the'),\n                          ('stop', 'in'),\n                          ('stop', 'of'),\n                          ('stop', 'FROM'),\n                          ('stop', 'at'),\n                          ('stop', 'it'),\n                          ])\n\ndef test_nouns():\n    assert_equal(lexicon.scan(\"bear\"), [('noun', 'bear')])\n    assert_equal(lexicon.scan(\"bears\"), [('noun', 'bear')])\n    result = lexicon.scan(\"bear princesses\")\n    assert_equal(result, [('noun', 'bear'),\n                          ('noun', 'princess')])\n\n\ndef test_numbers():\n    assert_equal(lexicon.scan(\"1234\"), [('number', '1234')])\n    result = lexicon.scan(\"3 91234 23098 8128 0\")\n    assert_equal(result, [('number', '3'),\n                          ('number', '91234'),\n                          ('number', '23098'),\n                          ('number', '8128'),\n                          ('number', '0'),\n                          ])\n\n\ndef test_errors():\n    assert_equal(lexicon.scan(\"ASDFADFASDF\"), [('error', 'ASDFADFASDF')])\n    result = lexicon.scan(\"Bear IA princess\")\n    assert_equal(result, [('noun', 'Bear'),\n                          ('error', 'IA'),\n                          ('noun', 'princess')\n                          ])\n"
  },
  {
    "path": "Python3/game/skeleton/test/map_test.py",
    "content": "from nose.tools import *\nfrom bin.map import *\n\ndef test_room():\n    gold = Room(\"GoldRoom\",\n                \"\"\" This room has gold in it you can grab. There's a \\\n    door to the north.\"\"\"\n                )\n    assert_equal(gold.name, \"GoldRoom\")\n    assert_equal(gold.paths, {})\n\ndef test_room_paths():\n    center = Room(\"Center\", \"Test room in the center.\")\n    north = Room(\"North\", \"Test room in the north.\")\n    south = Room(\"South\", \"Test room in the south.\")\n\n    center.add_paths({'north': north, 'south': south})\n    assert_equal(center.go('north'), north)\n    assert_equal(center.go('south'), south)\n    \ndef test_map():\n    start = Room(\"Start\", \"You can go west and down a hole.\")\n    west = Room(\"Trees\", \"There are trees here, you can go east.\")\n    down = Room(\"Dungeon\", \"It's dark down here, you can go up.\")\n\n    start.add_paths({'west': west, 'down': down})\n    west.add_paths({'east': start})\n    down.add_paths({'up': start})\n\n    assert_equal(start.go('west'), west)\n    assert_equal(start.go('west').go('east'), start)\n    assert_equal(start.go('down').go('up'), start)\n\ndef test_gothon_game_map():\n    assert_equal(START.go('shoot!'), generic_death)\n    assert_equal(START.go('dodge!'), generic_death)\n\n    room = START.go('tell a joke')\n    assert_equal(room, laser_weapon_armory)\n\n    dead = Room(\"death\", \"Oh you died\")\n    assert_equal(dead.name, \"death\")\n    assert_equal(dead.description, \"Oh you died\")\n\n"
  },
  {
    "path": "Python3/game/skeleton/test/parser_test.py",
    "content": "from nose.tools import *\nfrom ex49.parser import *\nfrom ex48.lexicon import *\nfrom copy import deepcopy\n\n\n# construct a test set that consists of several test lists\nglobal_test_lists = [ scan('south'), scan('door'), scan('go'), scan('to'),\n                      scan('234'), scan('error123'), scan('the east door'), scan('go to east'),\n                      scan('bear go to the door'), scan('the princess kill 10 bears') \n                    ]\n\n# the type of the the first tuple for each test list\ntest_types = ['direction', 'noun', 'verb', 'stop', 'number', 'error',\n               'stop', 'verb', 'noun', 'stop', None]\n\nlist_len = len(global_test_lists)\n\n\ndef test_peek():\n    ''' test peek function '''\n    test_lists = deepcopy(global_test_lists)\n    for i in range(list_len):\n        test_list = test_lists[i]\n        expected_word = test_types[i]\n        assert_equal(peek(test_list), expected_word)\n\n\ndef test_match():\n    ''' test match function '''\n    test_lists = deepcopy(global_test_lists)\n    for i in range(list_len):\n        test_list = test_lists[i]\n        test_type = test_types[i]\n        if len(test_list) > 0:\n            expected_tuple = test_list[0]\n        else:\n            expected_tuple = None\n        assert_equal(match(test_list, test_type), expected_tuple)\n\n\n\ndef test_skip():\n    ''' test skip function '''\n    test_lists = deepcopy(global_test_lists)\n    expected_lists1 = [scan('south'), scan('door'), scan('go'), [], scan('234'), scan('error123'),\n                       scan('east door'), scan('go to east'), scan('bear go to the door'),\n                       scan('princess kill 10 bear'), []]\n\n    for i in range(list_len):\n        test_list = test_lists[i]\n        expected_list = expected_lists1[i]\n        skip(test_list, 'stop')\n        assert_equal(test_list, expected_list)\n\n    test_list2 = [('error', 'error123')]\n    expected_list2 = []\n    skip(test_list2, 'error')\n    assert_equal(test_list2, expected_list2)\n\n\n\ndef test_parse_verb():\n    ''' test parse_verb function '''\n    parser = Parser()\n    # test good situations\n    test_lists_good =  [scan('go'), scan('go to east'), scan('to error123 eat')] \n    \n    expected_lists = [scan('go'), scan('go'), scan('eat')]\n        \n    for i in range(len(test_lists_good)):\n        test_list = test_lists_good[i]\n        expected_list = expected_lists[i]\n        assert_equal(parser.parse_verb(test_list), *expected_list)\n    \n    # test bad situations\n    test_lists_bad = [scan('south'), scan('door'), scan('234'), scan('east door'),\n                       scan('error123'), scan('to'),\n                      scan('bear go to the door'), scan('the princess kill 10 bear'), []]\n    for i in range(len(test_lists_bad)):\n        test_list = test_lists_bad[i]\n        assert_raises(ParserError, parser.parse_verb, test_list)\n\n\ndef test_parse_num():\n    ''' test parse_num function '''\n    parser = Parser()\n    # test good situations\n    test_lists_good = [scan('302'), scan('to error123 302')]\n    expected_lists = [scan('302'), scan('302')]\n        \n    for i in range(len(test_lists_good)):\n        test_list = test_lists_good[i]\n        expected_list = expected_lists[i]\n        assert_equal(parser.parse_num(test_list), *expected_list)\n    \n    # test bad situations\n    test_lists_bad = [scan('south'), scan('door'), scan('to'), scan('error123'), scan('east door'),\n                      scan('bear go to the door'), scan('the princess kill 10 bear'),[]]\n    \n    \n    for i in range(len(test_lists_bad)):\n        test_list = test_lists_bad[i]\n        assert_equal(parser.parse_num(test_list), None)\n\n\ndef test_parse_object():\n    ''' test parse_object function '''\n    parser = Parser()\n    # test good situations\n    test_lists_good =  [scan('south'), scan('door'), scan('the bear'), scan('east door'),\n                        scan('bear go to the door'), scan('the princess kill 10 bear')]\n    \n    expected_lists = [scan('south'), scan('door'), scan('bear'),\n                      scan('east'), scan('bear'), scan('princess')]\n        \n    for i in range(len(test_lists_good)):\n        test_list = test_lists_good[i]\n        expected_list = expected_lists[i]\n        assert_equal(parser.parse_object(test_list), *expected_list)\n    \n    # test bad situations\n    test_lists_bad = [scan('go'), scan('to'), scan('234'), scan('error123'), scan('go to east'), []]\n    for i in range(len(test_lists_bad)):\n        test_list = test_lists_bad[i]\n        assert_raises(ParserError, parser.parse_object, test_list)\n        \n\ndef test_class_sentence():\n    # test good situations\n    test_lists_good =  [scan('bear go east'), scan('princess kill bear'), scan(\n                        'princess kill 10 bears')]\n\n    expected_nums = [1, 1, 10]\n    expected_objects = ['east', 'bear', 'bear']\n        \n    for i in range(len(test_lists_good)):\n        test_list = test_lists_good[i]\n        test_num = expected_nums[i]\n        test_object = expected_objects[i]\n        \n        sentence = Sentence(*test_list)\n        assert_equal(sentence.subject, test_list[0][1])\n        assert_equal(sentence.verb, test_list[1][1])\n        assert_equal(sentence.num, test_num)\n        assert_equal(sentence.object, test_object)\n        \n    # test bad situations, for more restrict checking\n    test_lists_bad =  [scan('south'), scan('bear'), scan('go'), scan('to'),\n                       scan('the'), scan('door'), scan('bear go to the door'),\n                       scan('the princess kill 10 bears'), []] \n\n    for i in range(len(test_lists_good)):\n        test_list = test_lists_bad[i]\n        assert_raises(TypeError, Sentence, *test_list)\n\n\ndef test_parse_subject():\n    ''' test parse_subject function '''\n    parser = Parser()\n    \n    test_lists =  [scan('error123 eat princess'), scan('go to east'),\n                   scan('go error123 to the carbinet door'), scan('kill 10 bears')]\n        \n    test_subjects = [scan('bear'), scan('princess'), scan('carbinet'), scan('princess')]\n    expected_verbs = ['eat', 'go', 'go', 'kill']\n    expected_objects = ['princess', 'east', 'carbinet', 'bear']\n    expected_nums = [1, 1, 1, 10]\n\n    for i in range(len(test_lists)):\n        test_list = test_lists[i]\n        test_subject = test_subjects[i]\n        expected_verb = expected_verbs[i]\n        expected_object = expected_objects[i]\n        expected_num = expected_nums[i]\n        sentence = parser.parse_subject(test_list, test_subject[0])        \n        assert_equal(sentence.subject, test_subject[0][1])\n        assert_equal(sentence.verb, expected_verb)\n        assert_equal(sentence.object, expected_object)\n        assert_equal(sentence.num, expected_num)\n\n\ndef test_parse_sentence():\n    ''' test parse_sentence function '''\n    parser = Parser()\n    # test good situations\n    test_lists1 =  [scan('bear go to the door'),\n                    scan('the princess kill 10 bears'),\n                    scan('kill the bear')]\n\n    expected_subjects = ['bear', 'princess', 'player']\n    expected_verbs = ['go', 'kill', 'kill']\n    expected_objects = ['door', 'bear', 'bear']\n    expected_nums = [1, 10, 1]\n        \n    for i in range(len(test_lists1)):\n        test_list = test_lists1[i]\n        sentence = parser.parse_sentence(test_list)\n        expected_subject = expected_subjects[i]\n        expected_verb = expected_verbs[i]\n        expected_object = expected_objects[i]\n        expected_num = expected_nums[i]\n        assert_equal(sentence.subject, expected_subject)\n        assert_equal(sentence.verb, expected_verb)\n        assert_equal(sentence.object, expected_object)\n        assert_equal(sentence.num, expected_num)\n\n    # test bad situations\n    test_lists2 =  [scan('234')]\n    for i in range(len(test_lists2)):\n        test_list = test_lists2[i]\n        assert_raises(ParserError, parser.parse_object, test_list)\n"
  },
  {
    "path": "Python3/game/skeleton/test/setup_test.py",
    "content": "from nose.tools import *\nimport ex47\n\ndef setup():\n    print(\"SETUP!\")\n\ndef teardown():\n    print(\"TEAR DOWN!\")\n\ndef test_basic():\n    print(\"I RAN!\")\n"
  },
  {
    "path": "Python3/game/skeleton/test/tools.py",
    "content": "from nose.tools import *\nimport re\n\ndef assert_response(resp, contains=None, matches=None, headers=None, status=\"200\"):\n    assert status in resp.status, \"Expected response %r not in %r\" % (status, resp.status)\n\n    if status == \"200\":\n        assert resp.data, \"Response data is empty.\"\n\n    if contains:\n        assert contains in resp.data, \"Response does not contain %r\" % contains\n\n    if matches:\n        reg = re.compile(matches)\n        assert reg.matches(resp.data), \"Response does not match %r\" % matches\n\n    if headers:\n        assert_equal(resp.headers, headers)\n"
  },
  {
    "path": "Python3/sample.txt",
    "content": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\nquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\ncillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\nproident, sunt in culpa qui officia deserunt mollit anim id est laborum."
  },
  {
    "path": "README.md",
    "content": "My answer for all exersices from Zed. A. Shaw [Learn Python the Hard Way](http://learnpythonthehardway.org/).\n\nAll the codes are  written in both Python2(2.7.5) and Python3(3.3.2).\n\nThe best way to check my solution step by step is to use `git log` command. For instance,\n\n``` sh\n$ git log -p Python2/ex04.py\n```\n\nAlternatively you can browse the history of any file on Github to see the change of it.\n\nIf you got a better answer, welcome to comment the code and share your version!\n\n### Screenshots ###\n\n1. The final web page game(ex52):\n\n![](./media/game.png)\n\n2. A little battle system(ex47):\n\n![](./media/battle.png)\n\n"
  }
]