code
stringlengths
1
1.49M
vector
listlengths
0
7.38k
snippet
listlengths
0
7.38k
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Mimic pyquick exercise -- optional extra exercise. Google's Python Class Read in the ...
[ [ 8, 0, 0.2656, 0.3542, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4583, 0.0104, 0, 0.66, 0.1429, 715, 0, 1, 0, 0, 715, 0, 0 ], [ 1, 0, 0.4688, 0.0104, 0, 0.66...
[ "\"\"\"Mimic pyquick exercise -- optional extra exercise.\nGoogle's Python Class\n\nRead in the file specified on the command line.\nDo a simple split() on whitespace to obtain all the words in the file.\nRather than read the file line by line, it's easier to read\nit into one giant string and split it once.", "i...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.2687, 0.1045, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 3 ], [ 14, 1, 0.2388, 0.0149, 1, 0.87, 0, 826, 1, 0, 0, 0, 0, 1, 0 ], [ 14, 1, 0.2537, 0.0149, 1, 0.87, ...
[ "def remove_adjacent(nums):\n i=1\n newlist=[]\n for i in range (len(nums)):\n if nums[i]!=nums[i-1]:\n newlist.append(nums[i])\n return newlist", " i=1", " newlist=[]", " for i in range (len(nums)):\n if nums[i]!=nums[i-1]:\n newlist.append(nums[i])", " if nums[i]!=nums[i-1]:\n ...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
[ [ 8, 0, 0.2423, 0.3093, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4124, 0.0103, 0, 0.66, 0.1429, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.4227, 0.0103, 0, 0.66...
[ "\"\"\"Wordcount exercise\nGoogle's Python class\n\nThe main() below is already defined and complete. It calls print_words()\nand print_top() functions which you write.\n\n1. For the --count flag, implement a print_words(filename) function that counts\nhow often each word appears in the text and prints:", "import...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import sys import re """Baby Names exercise Define the extract_names() function below and c...
[ [ 1, 0, 0.1324, 0.0147, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.1471, 0.0147, 0, 0.66, 0.2, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 8, 0, 0.3456, 0.3529, 0, 0.6...
[ "import sys", "import re", "\"\"\"Baby Names exercise\n\nDefine the extract_names() function below and change main()\nto call it.\n\nFor writing regex, it's nice to include a copy of the target\ntext for inspiration.", "def extract_names(filename):\n \"\"\"\n Given a file name for baby.html, returns a list ...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import sys import re """Baby Names exercise Define the extract_names() function below and c...
[ [ 1, 0, 0.1324, 0.0147, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.1471, 0.0147, 0, 0.66, 0.2, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 8, 0, 0.3456, 0.3529, 0, 0.6...
[ "import sys", "import re", "\"\"\"Baby Names exercise\n\nDefine the extract_names() function below and change main()\nto call it.\n\nFor writing regex, it's nice to include a copy of the target\ntext for inspiration.", "def extract_names(filename):\n \"\"\"\n Given a file name for baby.html, returns a list ...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """A tiny Python program to check that Python is working. Try running this program from t...
[ [ 8, 0, 0.4091, 0.303, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.6061, 0.0303, 0, 0.66, 0.3333, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.7879, 0.2121, 0, 0.66,...
[ "\"\"\"A tiny Python program to check that Python is working.\nTry running this program from the command line like this:\n python hello.py\n python hello.py Alice\nThat should print:\n Hello World -or- Hello Alice\nTry changing the 'Hello' to 'Howdy' and run again.\nOnce you have that working, you're ready for c...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """A tiny Python program to check that Python is working. Try running this program from t...
[ [ 8, 0, 0.4091, 0.303, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.6061, 0.0303, 0, 0.66, 0.3333, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.7879, 0.2121, 0, 0.66,...
[ "\"\"\"A tiny Python program to check that Python is working.\nTry running this program from the command line like this:\n python hello.py\n python hello.py Alice\nThat should print:\n Hello World -or- Hello Alice\nTry changing the 'Hello' to 'Howdy' and run again.\nOnce you have that working, you're ready for c...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import sys import re import os import shutil import commands """Copy Special exercise """ #...
[ [ 1, 0, 0.1667, 0.0185, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.1852, 0.0185, 0, 0.66, 0.1429, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 1, 0, 0.2037, 0.0185, 0, ...
[ "import sys", "import re", "import os", "import shutil", "import commands", "\"\"\"Copy Special exercise\n\"\"\"", "def main():\n # This basic command line argument parsing code is provided.\n # Add code to call your functions below.\n\n # Make a list of command line arguments, omitting the [0] eleme...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import sys import re import os import shutil import commands """Copy Special exercise """ #...
[ [ 1, 0, 0.1667, 0.0185, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.1852, 0.0185, 0, 0.66, 0.1429, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 1, 0, 0.2037, 0.0185, 0, ...
[ "import sys", "import re", "import os", "import shutil", "import commands", "\"\"\"Copy Special exercise\n\"\"\"", "def main():\n # This basic command line argument parsing code is provided.\n # Add code to call your functions below.\n\n # Make a list of command line arguments, omitting the [0] eleme...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import os import re import sys import urllib """Logpuzzle exercise Given an apache logfile, ...
[ [ 1, 0, 0.1475, 0.0164, 0, 0.66, 0, 688, 0, 1, 0, 0, 688, 0, 0 ], [ 1, 0, 0.1639, 0.0164, 0, 0.66, 0.125, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 1, 0, 0.1803, 0.0164, 0, 0...
[ "import os", "import re", "import sys", "import urllib", "\"\"\"Logpuzzle exercise\nGiven an apache logfile, find the puzzle urls and download the images.\n\nHere's what a puzzle url looks like:\n10.254.254.28 - - [06/Aug/2007:00:13:48 -0700] \"GET /~foo/puzzle-bar-aaab.jpg HTTP/1.0\" 302 528 \"-\" \"Mozill...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import os import re import sys import urllib """Logpuzzle exercise Given an apache logfile, ...
[ [ 1, 0, 0.1475, 0.0164, 0, 0.66, 0, 688, 0, 1, 0, 0, 688, 0, 0 ], [ 1, 0, 0.1639, 0.0164, 0, 0.66, 0.125, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 1, 0, 0.1803, 0.0164, 0, 0...
[ "import os", "import re", "import sys", "import urllib", "\"\"\"Logpuzzle exercise\nGiven an apache logfile, find the puzzle urls and download the images.\n\nHere's what a puzzle url looks like:\n10.254.254.28 - - [06/Aug/2007:00:13:48 -0700] \"GET /~foo/puzzle-bar-aaab.jpg HTTP/1.0\" 302 528 \"-\" \"Mozill...
#!/usr/bin/python def remove_adjacent(nums): result = [] for num in nums: if len(result) == 0 or num != result[-1]: result.append(num) return result def linear_merge(list1, list2): result = [] while len(list1) and len(list2): if list1[0] < list2[0]: result.append(list1.pop(0)) else: ...
[ [ 2, 0, 0.1071, 0.1429, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 2 ], [ 14, 1, 0.0714, 0.0238, 1, 0.22, 0, 51, 0, 0, 0, 0, 0, 5, 0 ], [ 6, 1, 0.119, 0.0714, 1, 0.22, ...
[ "def remove_adjacent(nums):\n result = []\n for num in nums:\n if len(result) == 0 or num != result[-1]:\n result.append(num)\n return result", " result = []", " for num in nums:\n if len(result) == 0 or num != result[-1]:\n result.append(num)", " if len(result) == 0 or num != result[-...
#!/usr/bin/python import sys def words(filename): count = {} input_file = open(filename, 'r') for line in input_file: words = line.split() for word in words: word = word.lower() if not word in count: count[word] = 1 else: count[word] = count[word] + 1 input_file...
[ [ 1, 0, 0.0645, 0.0161, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.2258, 0.2097, 0, 0.66, 0.1667, 376, 0, 1, 1, 0, 0, 0, 4 ], [ 14, 1, 0.1452, 0.0161, 1, 0...
[ "import sys", "def words(filename):\n count = {} \n input_file = open(filename, 'r')\n for line in input_file:\n words = line.split()\n for word in words:\n word = word.lower()\n if not word in count:", " count = {}", " input_file = open(filename, 'r')", " for line in input_file:\n ...
#!/usr/bin/python def remove_adjacent(nums): result = [] for num in nums: if len(result) == 0 or num != result[-1]: result.append(num) return result def linear_merge(list1, list2): result = [] while len(list1) and len(list2): if list1[0] < list2[0]: result.append(list1.pop(0)) else: ...
[ [ 2, 0, 0.1071, 0.1429, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 2 ], [ 14, 1, 0.0714, 0.0238, 1, 0.03, 0, 51, 0, 0, 0, 0, 0, 5, 0 ], [ 6, 1, 0.119, 0.0714, 1, 0.03, ...
[ "def remove_adjacent(nums):\n result = []\n for num in nums:\n if len(result) == 0 or num != result[-1]:\n result.append(num)\n return result", " result = []", " for num in nums:\n if len(result) == 0 or num != result[-1]:\n result.append(num)", " if len(result) == 0 or num != result[-...
#!/usr/bin/python import sys def words(filename): count = {} input_file = open(filename, 'r') for line in input_file: words = line.split() for word in words: word = word.lower() if not word in count: count[word] = 1 else: count[word] = count[word] + 1 input_file...
[ [ 1, 0, 0.0645, 0.0161, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.2258, 0.2097, 0, 0.66, 0.1667, 376, 0, 1, 1, 0, 0, 0, 4 ], [ 14, 1, 0.1452, 0.0161, 1, 0...
[ "import sys", "def words(filename):\n count = {} \n input_file = open(filename, 'r')\n for line in input_file:\n words = line.split()\n for word in words:\n word = word.lower()\n if not word in count:", " count = {}", " input_file = open(filename, 'r')", " for line in input_file:\n ...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.2778, 0.1528, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 2 ], [ 4, 1, 0.2292, 0.0278, 1, 0.37, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 13, 2, 0.2361, 0.0139, 2, 0.79, ...
[ "def remove_adjacent(nums):\n if nums == []:\n return nums\n last = nums[0]\n mlist = []\n mlist.append(last)\n for i in nums[1:]:\n if i!= last:", " if nums == []:\n return nums", " return nums", " last = nums[0]", " mlist = []", " mlist.append(last)", " for i in nums[1:]:\n if...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
[ [ 8, 0, 0.2398, 0.3061, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4082, 0.0102, 0, 0.66, 0.1429, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.4184, 0.0102, 0, 0.66...
[ "\"\"\"Wordcount exercise\nGoogle's Python class\n\nThe main() below is already defined and complete. It calls print_words()\nand print_top() functions which you write.\n\n1. For the --count flag, implement a print_words(filename) function that counts\nhow often each word appears in the text and prints:", "import...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.2778, 0.1528, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 2 ], [ 4, 1, 0.2292, 0.0278, 1, 0.18, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 13, 2, 0.2361, 0.0139, 2, 0.4, 0...
[ "def remove_adjacent(nums):\n if nums == []:\n return nums\n last = nums[0]\n mlist = []\n mlist.append(last)\n for i in nums[1:]:\n if i!= last:", " if nums == []:\n return nums", " return nums", " last = nums[0]", " mlist = []", " mlist.append(last)", " for i in nums[1:]:\n if...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
[ [ 8, 0, 0.2398, 0.3061, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4082, 0.0102, 0, 0.66, 0.1429, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.4184, 0.0102, 0, 0.66...
[ "\"\"\"Wordcount exercise\nGoogle's Python class\n\nThe main() below is already defined and complete. It calls print_words()\nand print_top() functions which you write.\n\n1. For the --count flag, implement a print_words(filename) function that counts\nhow often each word appears in the text and prints:", "import...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Mimic pyquick exercise -- optional extra exercise. Google's Python Class Read in the ...
[ [ 8, 0, 0.2576, 0.3434, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4444, 0.0101, 0, 0.66, 0.1429, 715, 0, 1, 0, 0, 715, 0, 0 ], [ 1, 0, 0.4545, 0.0101, 0, 0.66...
[ "\"\"\"Mimic pyquick exercise -- optional extra exercise.\nGoogle's Python Class\n\nRead in the file specified on the command line.\nDo a simple split() on whitespace to obtain all the words in the file.\nRather than read the file line by line, it's easier to read\nit into one giant string and split it once.", "i...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.2643, 0.1143, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 3 ], [ 14, 1, 0.2429, 0.0143, 1, 0.32, 0, 826, 1, 0, 0, 0, 0, 1, 0 ], [ 14, 1, 0.2571, 0.0143, 1, 0.32, ...
[ "def remove_adjacent(nums):\n # +++your code here+++\n i=1\n newlist=[]\n for i in range (len(nums)):\n if nums[i]!=nums[i-1]:\n newlist.append(nums[i])\n return newlist", " i=1", " newlist=[]", " for i in range (len(nums)):\n if nums[i]!=nums[i-1]:\n newlist.append(nums[i])", " i...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
[ [ 8, 0, 0.2398, 0.3061, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4082, 0.0102, 0, 0.66, 0.1429, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.4184, 0.0102, 0, 0.66...
[ "\"\"\"Wordcount exercise\nGoogle's Python class\n\nThe main() below is already defined and complete. It calls print_words()\nand print_top() functions which you write.\n\n1. For the --count flag, implement a print_words(filename) function that counts\nhow often each word appears in the text and prints:", "import...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Mimic pyquick exercise -- optional extra exercise. Google's Python Class Read in the ...
[ [ 8, 0, 0.2576, 0.3434, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4444, 0.0101, 0, 0.66, 0.1429, 715, 0, 1, 0, 0, 715, 0, 0 ], [ 1, 0, 0.4545, 0.0101, 0, 0.66...
[ "\"\"\"Mimic pyquick exercise -- optional extra exercise.\nGoogle's Python Class\n\nRead in the file specified on the command line.\nDo a simple split() on whitespace to obtain all the words in the file.\nRather than read the file line by line, it's easier to read\nit into one giant string and split it once.", "i...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.2643, 0.1143, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 3 ], [ 14, 1, 0.2429, 0.0143, 1, 0.57, 0, 826, 1, 0, 0, 0, 0, 1, 0 ], [ 14, 1, 0.2571, 0.0143, 1, 0.57, ...
[ "def remove_adjacent(nums):\n # +++your code here+++\n i=1\n newlist=[]\n for i in range (len(nums)):\n if nums[i]!=nums[i-1]:\n newlist.append(nums[i])\n return newlist", " i=1", " newlist=[]", " for i in range (len(nums)):\n if nums[i]!=nums[i-1]:\n newlist.append(nums[i])", " i...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
[ [ 8, 0, 0.2398, 0.3061, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4082, 0.0102, 0, 0.66, 0.1429, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.4184, 0.0102, 0, 0.66...
[ "\"\"\"Wordcount exercise\nGoogle's Python class\n\nThe main() below is already defined and complete. It calls print_words()\nand print_top() functions which you write.\n\n1. For the --count flag, implement a print_words(filename) function that counts\nhow often each word appears in the text and prints:", "import...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.3118, 0.2824, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 4 ], [ 14, 1, 0.2, 0.0118, 1, 0.68, 0, 714, 3, 1, 0, 0, 890, 10, 1 ], [ 4, 1, 0.2176, 0.0235, 1, 0.68, ...
[ "def remove_adjacent(nums):\n # +++your code here+++\n\tsize=len(nums);\n\tif size == 0:\n\t\treturn nums;\n\ti=0;\n\tj=0;\n\tcount=0;", "\tsize=len(nums);", "\tif size == 0:\n\t\treturn nums;", "\t\treturn nums;", "\ti=0;", "\tj=0;", "\tcount=0;", "\tsize_lst=0;", "\tlst=[];", "\tlst.append(nums...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.3118, 0.2824, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 4 ], [ 14, 1, 0.2, 0.0118, 1, 0.29, 0, 714, 3, 1, 0, 0, 890, 10, 1 ], [ 4, 1, 0.2176, 0.0235, 1, 0.29, ...
[ "def remove_adjacent(nums):\n # +++your code here+++\n\tsize=len(nums);\n\tif size == 0:\n\t\treturn nums;\n\ti=0;\n\tj=0;\n\tcount=0;", "\tsize=len(nums);", "\tif size == 0:\n\t\treturn nums;", "\t\treturn nums;", "\ti=0;", "\tj=0;", "\tcount=0;", "\tsize_lst=0;", "\tlst=[];", "\tlst.append(nums...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.2562, 0.15, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 1 ], [ 14, 1, 0.2125, 0.0125, 1, 0.69, 0, 756, 1, 0, 0, 0, 0, 1, 0 ], [ 14, 1, 0.225, 0.0125, 1, 0.69, ...
[ "def remove_adjacent(nums):\n # +++your code here+++\n flag = 1\n new_list = []\n for i in nums:\n \tfor j in new_list:\n \t\tif i == j:\n \t\t\tflag = 0", " flag = 1", " new_list = []", " for i in nums:\n \tfor j in new_list:\n \t\tif i == j:\n \t\t\tflag = 0\n \tif flag == 1:\n \t\tnew_list.a...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
[ [ 8, 0, 0.25, 0.3191, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4255, 0.0106, 0, 0.66, 0.1667, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.5585, 0.1277, 0, 0.66, ...
[ "\"\"\"Wordcount exercise\nGoogle's Python class\n\nThe main() below is already defined and complete. It calls print_words()\nand print_top() functions which you write.\n\n1. For the --count flag, implement a print_words(filename) function that counts\nhow often each word appears in the text and prints:", "import...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.2562, 0.15, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 1 ], [ 14, 1, 0.2125, 0.0125, 1, 0.37, 0, 756, 1, 0, 0, 0, 0, 1, 0 ], [ 14, 1, 0.225, 0.0125, 1, 0.37, ...
[ "def remove_adjacent(nums):\n # +++your code here+++\n flag = 1\n new_list = []\n for i in nums:\n \tfor j in new_list:\n \t\tif i == j:\n \t\t\tflag = 0", " flag = 1", " new_list = []", " for i in nums:\n \tfor j in new_list:\n \t\tif i == j:\n \t\t\tflag = 0\n \tif flag == 1:\n \t\tnew_list.a...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
[ [ 8, 0, 0.25, 0.3191, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4255, 0.0106, 0, 0.66, 0.1667, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.5585, 0.1277, 0, 0.66, ...
[ "\"\"\"Wordcount exercise\nGoogle's Python class\n\nThe main() below is already defined and complete. It calls print_words()\nand print_top() functions which you write.\n\n1. For the --count flag, implement a print_words(filename) function that counts\nhow often each word appears in the text and prints:", "import...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.2778, 0.1528, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 2 ], [ 4, 1, 0.2292, 0.0278, 1, 0.62, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 13, 2, 0.2361, 0.0139, 2, 0.45, ...
[ "def remove_adjacent(nums):\n if nums == []:\n return nums\n last = nums[0]\n mlist = []\n mlist.append(last)\n for i in nums[1:]:\n if i!= last:", " if nums == []:\n return nums", " return nums", " last = nums[0]", " mlist = []", " mlist.append(last)", " for i in nums[1:]:\n if...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
[ [ 8, 0, 0.2398, 0.3061, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4082, 0.0102, 0, 0.66, 0.1429, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.4184, 0.0102, 0, 0.66...
[ "\"\"\"Wordcount exercise\nGoogle's Python class\n\nThe main() below is already defined and complete. It calls print_words()\nand print_top() functions which you write.\n\n1. For the --count flag, implement a print_words(filename) function that counts\nhow often each word appears in the text and prints:", "import...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.2778, 0.1528, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 2 ], [ 4, 1, 0.2292, 0.0278, 1, 0.89, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 13, 2, 0.2361, 0.0139, 2, 0.72, ...
[ "def remove_adjacent(nums):\n if nums == []:\n return nums\n last = nums[0]\n mlist = []\n mlist.append(last)\n for i in nums[1:]:\n if i!= last:", " if nums == []:\n return nums", " return nums", " last = nums[0]", " mlist = []", " mlist.append(last)", " for i in nums[1:]:\n if...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
[ [ 8, 0, 0.2398, 0.3061, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.4082, 0.0102, 0, 0.66, 0.1429, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.4184, 0.0102, 0, 0.66...
[ "\"\"\"Wordcount exercise\nGoogle's Python class\n\nThe main() below is already defined and complete. It calls print_words()\nand print_top() functions which you write.\n\n1. For the --count flag, implement a print_words(filename) function that counts\nhow often each word appears in the text and prints:", "import...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Mimic pyquick exercise -- optional extra exercise. Google's Python Class Read in the ...
[ [ 8, 0, 0.3592, 0.4789, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.6197, 0.0141, 0, 0.66, 0.1667, 715, 0, 1, 0, 0, 715, 0, 0 ], [ 1, 0, 0.6338, 0.0141, 0, 0.66...
[ "\"\"\"Mimic pyquick exercise -- optional extra exercise.\nGoogle's Python Class\n\nRead in the file specified on the command line.\nDo a simple split() on whitespace to obtain all the words in the file.\nRather than read the file line by line, it's easier to read\nit into one giant string and split it once.", "i...
#!/usr/bin/python import sys print "hello world!"
[ [ 1, 0, 0.75, 0.25, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 8, 0, 1, 0.25, 0, 0.66, 1, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "import sys", "print(\"hello world!\")" ]
#!/usr/bin/python # D. Given a list of numbers, return a list where # all adjacent == elements have been reduced to a single element, # so [1, 2, 2, 3] returns [1, 2, 3]. You may create a new list or # modify the passed in list. def remove_adjacent(nums): arr=[] for n in nums: if n not in arr: arr.appen...
[ [ 2, 0, 0.1939, 0.1224, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 1 ], [ 14, 1, 0.1633, 0.0204, 1, 0.14, 0, 395, 0, 0, 0, 0, 0, 5, 0 ], [ 6, 1, 0.2041, 0.0612, 1, 0.14, ...
[ "def remove_adjacent(nums):\n arr=[]\n for n in nums:\n if n not in arr:\n arr.append(n)\n return arr", " arr=[]", " for n in nums:\n if n not in arr:\n arr.append(n)", " if n not in arr:\n arr.append(n)", " arr.append(n)", " return arr", "def linear_merge(list1, list2...
#!/usr/bin/python import sys print "hello world!"
[ [ 1, 0, 0.75, 0.25, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 8, 0, 1, 0.25, 0, 0.66, 1, 535, 3, 1, 0, 0, 0, 0, 1 ] ]
[ "import sys", "print(\"hello world!\")" ]
#!/usr/bin/python import sys def read_and_count(filename): words_map={} file=open(filename, 'r') for str in file: arr=str.split() for s in arr: s=s.lower(); if s not in words_map: words_map[s] = 1 else: words_map[s] +=1 file.close() return words_map # def print_w...
[ [ 1, 0, 0.0577, 0.0192, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.2115, 0.25, 0, 0.66, 0.1667, 726, 0, 1, 1, 0, 0, 0, 4 ], [ 14, 1, 0.1154, 0.0192, 1, 0.2...
[ "import sys", "def read_and_count(filename):\n words_map={}\n file=open(filename, 'r')\n for str in file:\n arr=str.split()\n for s in arr:\n s=s.lower();\n if s not in words_map:", " words_map={}", " file=open(filename, 'r')", " for str in file:\n arr=str.split()\n for s in arr:...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Mimic pyquick exercise -- optional extra exercise. Google's Python Class Read in the ...
[ [ 8, 0, 0.3592, 0.4789, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.6197, 0.0141, 0, 0.66, 0.1667, 715, 0, 1, 0, 0, 715, 0, 0 ], [ 1, 0, 0.6338, 0.0141, 0, 0.66...
[ "\"\"\"Mimic pyquick exercise -- optional extra exercise.\nGoogle's Python Class\n\nRead in the file specified on the command line.\nDo a simple split() on whitespace to obtain all the words in the file.\nRather than read the file line by line, it's easier to read\nit into one giant string and split it once.", "i...
#!/usr/bin/python # D. Given a list of numbers, return a list where # all adjacent == elements have been reduced to a single element, # so [1, 2, 2, 3] returns [1, 2, 3]. You may create a new list or # modify the passed in list. def remove_adjacent(nums): arr=[] for n in nums: if n not in arr: arr.appen...
[ [ 2, 0, 0.1939, 0.1224, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 1 ], [ 14, 1, 0.1633, 0.0204, 1, 0.6, 0, 395, 0, 0, 0, 0, 0, 5, 0 ], [ 6, 1, 0.2041, 0.0612, 1, 0.6, ...
[ "def remove_adjacent(nums):\n arr=[]\n for n in nums:\n if n not in arr:\n arr.append(n)\n return arr", " arr=[]", " for n in nums:\n if n not in arr:\n arr.append(n)", " if n not in arr:\n arr.append(n)", " arr.append(n)", " return arr", "def linear_merge(list1, list2...
#!/usr/bin/python import sys def read_and_count(filename): words_map={} file=open(filename, 'r') for str in file: arr=str.split() for s in arr: s=s.lower(); if s not in words_map: words_map[s] = 1 else: words_map[s] +=1 file.close() return words_map # def print_w...
[ [ 1, 0, 0.0577, 0.0192, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.2115, 0.25, 0, 0.66, 0.1667, 726, 0, 1, 1, 0, 0, 0, 4 ], [ 14, 1, 0.1154, 0.0192, 1, 0.9...
[ "import sys", "def read_and_count(filename):\n words_map={}\n file=open(filename, 'r')\n for str in file:\n arr=str.split()\n for s in arr:\n s=s.lower();\n if s not in words_map:", " words_map={}", " file=open(filename, 'r')", " for str in file:\n arr=str.split()\n for s in arr:...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Mimic pyquick exercise -- optional extra exercise. Google's Python Class Read in the ...
[ [ 8, 0, 0.3592, 0.4789, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.6197, 0.0141, 0, 0.66, 0.1667, 715, 0, 1, 0, 0, 715, 0, 0 ], [ 1, 0, 0.6338, 0.0141, 0, 0.66...
[ "\"\"\"Mimic pyquick exercise -- optional extra exercise.\nGoogle's Python Class\n\nRead in the file specified on the command line.\nDo a simple split() on whitespace to obtain all the words in the file.\nRather than read the file line by line, it's easier to read\nit into one giant string and split it once.", "i...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.254, 0.0476, 0, 0.66, 0, 855, 0, 1, 0, 0, 0, 0, 0 ], [ 13, 1, 0.2698, 0.0159, 1, 0.45, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0.3968, 0.0476, 0, 0.66, 0...
[ "def remove_adjacent(nums):\n # +++your code here+++\n return", " return", "def linear_merge(list1, list2):\n # +++your code here+++\n return", " return", "def test(got, expected):\n if got == expected:\n prefix = ' OK '\n else:\n prefix = ' X '\n print('%s got: %s expected: %s' % (prefix, r...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
[ [ 8, 0, 0.3456, 0.4412, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.5882, 0.0147, 0, 0.66, 0.3333, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.8603, 0.2059, 0, 0.66...
[ "\"\"\"Wordcount exercise\nGoogle's Python class\n\nThe main() below is already defined and complete. It calls print_words()\nand print_top() functions which you write.\n\n1. For the --count flag, implement a print_words(filename) function that counts\nhow often each word appears in the text and prints:", "import...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Mimic pyquick exercise -- optional extra exercise. Google's Python Class Read in the ...
[ [ 8, 0, 0.3592, 0.4789, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.6197, 0.0141, 0, 0.66, 0.1667, 715, 0, 1, 0, 0, 715, 0, 0 ], [ 1, 0, 0.6338, 0.0141, 0, 0.66...
[ "\"\"\"Mimic pyquick exercise -- optional extra exercise.\nGoogle's Python Class\n\nRead in the file specified on the command line.\nDo a simple split() on whitespace to obtain all the words in the file.\nRather than read the file line by line, it's easier to read\nit into one giant string and split it once.", "i...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ # Additional basic list exercises # D. Given a list of numbers, return a list where # al...
[ [ 2, 0, 0.254, 0.0476, 0, 0.66, 0, 855, 0, 1, 0, 0, 0, 0, 0 ], [ 13, 1, 0.2698, 0.0159, 1, 0.03, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 2, 0, 0.3968, 0.0476, 0, 0.66, 0...
[ "def remove_adjacent(nums):\n # +++your code here+++\n return", " return", "def linear_merge(list1, list2):\n # +++your code here+++\n return", " return", "def test(got, expected):\n if got == expected:\n prefix = ' OK '\n else:\n prefix = ' X '\n print('%s got: %s expected: %s' % (prefix, r...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and comp...
[ [ 8, 0, 0.3456, 0.4412, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.5882, 0.0147, 0, 0.66, 0.3333, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.8603, 0.2059, 0, 0.66...
[ "\"\"\"Wordcount exercise\nGoogle's Python class\n\nThe main() below is already defined and complete. It calls print_words()\nand print_top() functions which you write.\n\n1. For the --count flag, implement a print_words(filename) function that counts\nhow often each word appears in the text and prints:", "import...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import sys import re """Baby Names exercise Define the extract_names() function below and c...
[ [ 1, 0, 0.1324, 0.0147, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.1471, 0.0147, 0, 0.66, 0.2, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 8, 0, 0.3456, 0.3529, 0, 0.6...
[ "import sys", "import re", "\"\"\"Baby Names exercise\n\nDefine the extract_names() function below and change main()\nto call it.\n\nFor writing regex, it's nice to include a copy of the target\ntext for inspiration.", "def extract_names(filename):\n \"\"\"\n Given a file name for baby.html, returns a list ...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import sys import re """Baby Names exercise Define the extract_names() function below and c...
[ [ 1, 0, 0.1324, 0.0147, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.1471, 0.0147, 0, 0.66, 0.2, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 8, 0, 0.3456, 0.3529, 0, 0.6...
[ "import sys", "import re", "\"\"\"Baby Names exercise\n\nDefine the extract_names() function below and change main()\nto call it.\n\nFor writing regex, it's nice to include a copy of the target\ntext for inspiration.", "def extract_names(filename):\n \"\"\"\n Given a file name for baby.html, returns a list ...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """A tiny Python program to check that Python is working. Try running this program from t...
[ [ 8, 0, 0.4091, 0.303, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.6061, 0.0303, 0, 0.66, 0.3333, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.7879, 0.2121, 0, 0.66,...
[ "\"\"\"A tiny Python program to check that Python is working.\nTry running this program from the command line like this:\n python hello.py\n python hello.py Alice\nThat should print:\n Hello World -or- Hello Alice\nTry changing the 'Hello' to 'Howdy' and run again.\nOnce you have that working, you're ready for c...
#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """A tiny Python program to check that Python is working. Try running this program from t...
[ [ 8, 0, 0.4091, 0.303, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.6061, 0.0303, 0, 0.66, 0.3333, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.7879, 0.2121, 0, 0.66,...
[ "\"\"\"A tiny Python program to check that Python is working.\nTry running this program from the command line like this:\n python hello.py\n python hello.py Alice\nThat should print:\n Hello World -or- Hello Alice\nTry changing the 'Hello' to 'Howdy' and run again.\nOnce you have that working, you're ready for c...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import sys import re import os import shutil import commands """Copy Special exercise """ #...
[ [ 1, 0, 0.1667, 0.0185, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.1852, 0.0185, 0, 0.66, 0.1429, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 1, 0, 0.2037, 0.0185, 0, ...
[ "import sys", "import re", "import os", "import shutil", "import commands", "\"\"\"Copy Special exercise\n\"\"\"", "def main():\n # This basic command line argument parsing code is provided.\n # Add code to call your functions below.\n\n # Make a list of command line arguments, omitting the [0] eleme...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import sys import re import os import shutil import commands """Copy Special exercise """ #...
[ [ 1, 0, 0.1667, 0.0185, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.1852, 0.0185, 0, 0.66, 0.1429, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 1, 0, 0.2037, 0.0185, 0, ...
[ "import sys", "import re", "import os", "import shutil", "import commands", "\"\"\"Copy Special exercise\n\"\"\"", "def main():\n # This basic command line argument parsing code is provided.\n # Add code to call your functions below.\n\n # Make a list of command line arguments, omitting the [0] eleme...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import os import re import sys import urllib """Logpuzzle exercise Given an apache logfile, ...
[ [ 1, 0, 0.1475, 0.0164, 0, 0.66, 0, 688, 0, 1, 0, 0, 688, 0, 0 ], [ 1, 0, 0.1639, 0.0164, 0, 0.66, 0.125, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 1, 0, 0.1803, 0.0164, 0, 0...
[ "import os", "import re", "import sys", "import urllib", "\"\"\"Logpuzzle exercise\nGiven an apache logfile, find the puzzle urls and download the images.\n\nHere's what a puzzle url looks like:\n10.254.254.28 - - [06/Aug/2007:00:13:48 -0700] \"GET /~foo/puzzle-bar-aaab.jpg HTTP/1.0\" 302 528 \"-\" \"Mozill...
#!/usr/bin/python # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ import os import re import sys import urllib """Logpuzzle exercise Given an apache logfile, ...
[ [ 1, 0, 0.1475, 0.0164, 0, 0.66, 0, 688, 0, 1, 0, 0, 688, 0, 0 ], [ 1, 0, 0.1639, 0.0164, 0, 0.66, 0.125, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 1, 0, 0.1803, 0.0164, 0, 0...
[ "import os", "import re", "import sys", "import urllib", "\"\"\"Logpuzzle exercise\nGiven an apache logfile, find the puzzle urls and download the images.\n\nHere's what a puzzle url looks like:\n10.254.254.28 - - [06/Aug/2007:00:13:48 -0700] \"GET /~foo/puzzle-bar-aaab.jpg HTTP/1.0\" 302 528 \"-\" \"Mozill...
#!/usr/bin/python -tt # D. Given a list of numbers, return a list where # all adjacent == elements have been reduced to a single element, # so [1, 2, 2, 3] returns [1, 2, 3]. You may create a new list or # modify the passed in list. def remove_adjacent(nums): array = [] for num in nums: if num not in array: ...
[ [ 2, 0, 0.19, 0.12, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 1 ], [ 14, 1, 0.16, 0.02, 1, 0.68, 0, 80, 0, 0, 0, 0, 0, 5, 0 ], [ 6, 1, 0.2, 0.06, 1, 0.68, 0.5, 328...
[ "def remove_adjacent(nums):\n array = []\n for num in nums:\n if num not in array:\n array.append(num)\n return array", " array = []", " for num in nums:\n if num not in array:\n array.append(num)", " if num not in array:\n array.append(num)", " array.append(num)", " ret...
#!/usr/bin/python -tt import sys # Define print_words(filename) and print_top(filename) functions. # You could write a helper utility function that reads a file # and builds and returns a word/count dict for it. # Then print_words() and print_top() can just call the utility function. def word_count_dict(filename):...
[ [ 1, 0, 0.0625, 0.0156, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.2812, 0.2031, 0, 0.66, 0.1667, 862, 0, 1, 1, 0, 0, 0, 4 ], [ 14, 1, 0.2031, 0.0156, 1, 0...
[ "import sys", "def word_count_dict(filename):\n word_count = {}\n my_file = open(filename, 'r')\n for line in my_file:\n words = line.split()\n for word in words:\n word = word.lower()\n if not word in word_count:", " word_count = {}", " my_file = open(filename, 'r')", " for line in my...
#!/usr/bin/python -tt # D. Given a list of numbers, return a list where # all adjacent == elements have been reduced to a single element, # so [1, 2, 2, 3] returns [1, 2, 3]. You may create a new list or # modify the passed in list. def remove_adjacent(nums): array = [] for num in nums: if num not in array: ...
[ [ 2, 0, 0.19, 0.12, 0, 0.66, 0, 855, 0, 1, 1, 0, 0, 0, 1 ], [ 14, 1, 0.16, 0.02, 1, 0.73, 0, 80, 0, 0, 0, 0, 0, 5, 0 ], [ 6, 1, 0.2, 0.06, 1, 0.73, 0.5, 328...
[ "def remove_adjacent(nums):\n array = []\n for num in nums:\n if num not in array:\n array.append(num)\n return array", " array = []", " for num in nums:\n if num not in array:\n array.append(num)", " if num not in array:\n array.append(num)", " array.append(num)", " ret...
#!/usr/bin/python -tt import sys # Define print_words(filename) and print_top(filename) functions. # You could write a helper utility function that reads a file # and builds and returns a word/count dict for it. # Then print_words() and print_top() can just call the utility function. def word_count_dict(filename):...
[ [ 1, 0, 0.0625, 0.0156, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 2, 0, 0.2812, 0.2031, 0, 0.66, 0.1667, 862, 0, 1, 1, 0, 0, 0, 4 ], [ 14, 1, 0.2031, 0.0156, 1, 0...
[ "import sys", "def word_count_dict(filename):\n word_count = {}\n my_file = open(filename, 'r')\n for line in my_file:\n words = line.split()\n for word in words:\n word = word.lower()\n if not word in word_count:", " word_count = {}", " my_file = open(filename, 'r')", " for line in my...
#!/usr/bin/env python # -*- encoding:utf8 -*- # protoc-gen-erl # Google's Protocol Buffers project, ported to lua. # https://code.google.com/p/protoc-gen-lua/ # # Copyright (c) 2010 , 林卓毅 (Zhuoyi Lin) netsnail@gmail.com # All rights reserved. # # Use, modification and distribution are subject to the "New BSD License" #...
[ [ 1, 0, 0.0289, 0.0022, 0, 0.66, 0, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.0311, 0.0022, 0, 0.66, 0.0417, 79, 0, 1, 0, 0, 79, 0, 0 ], [ 1, 0, 0.0333, 0.0022, 0, 0....
[ "import sys", "import os.path as path", "from cStringIO import StringIO", "import plugin_pb2", "import google.protobuf.descriptor_pb2 as descriptor_pb2", "_packages = {}", "_files = {}", "_message = {}", "FDP = plugin_pb2.descriptor_pb2.FieldDescriptorProto", "if sys.platform == \"win32\":\n im...
''' Module which brings history information about files from Mercurial. @author: Rodrigo Damazio ''' import re import subprocess REVISION_REGEX = re.compile(r'(?P<hash>[0-9a-f]{12}):.*') def _GetOutputLines(args): ''' Runs an external process and returns its output as a list of lines. @param args: the argume...
[ [ 8, 0, 0.0319, 0.0532, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.0745, 0.0106, 0, 0.66, 0.1429, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 1, 0, 0.0851, 0.0106, 0, 0.66...
[ "'''\nModule which brings history information about files from Mercurial.\n\n@author: Rodrigo Damazio\n'''", "import re", "import subprocess", "REVISION_REGEX = re.compile(r'(?P<hash>[0-9a-f]{12}):.*')", "def _GetOutputLines(args):\n '''\n Runs an external process and returns its output as a list of lines...
#!/usr/bin/python ''' Entry point for My Tracks i18n tool. @author: Rodrigo Damazio ''' import mytracks.files import mytracks.translate import mytracks.validate import sys def Usage(): print 'Usage: %s <command> [<language> ...]\n' % sys.argv[0] print 'Commands are:' print ' cleanup' print ' translate' p...
[ [ 8, 0, 0.0417, 0.0521, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.0833, 0.0104, 0, 0.66, 0.125, 640, 0, 1, 0, 0, 640, 0, 0 ], [ 1, 0, 0.0938, 0.0104, 0, 0.66,...
[ "'''\nEntry point for My Tracks i18n tool.\n\n@author: Rodrigo Damazio\n'''", "import mytracks.files", "import mytracks.translate", "import mytracks.validate", "import sys", "def Usage():\n print('Usage: %s <command> [<language> ...]\\n' % sys.argv[0])\n print('Commands are:')\n print(' cleanup')\n p...
''' Module which prompts the user for translations and saves them. TODO: implement @author: Rodrigo Damazio ''' class Translator(object): ''' classdocs ''' def __init__(self, language): ''' Constructor ''' self._language = language def Translate(self, string_names): print string_names
[ [ 8, 0, 0.1905, 0.3333, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 3, 0, 0.7143, 0.619, 0, 0.66, 1, 229, 0, 2, 0, 0, 186, 0, 1 ], [ 8, 1, 0.5238, 0.1429, 1, 0.79, ...
[ "'''\nModule which prompts the user for translations and saves them.\n\nTODO: implement\n\n@author: Rodrigo Damazio\n'''", "class Translator(object):\n '''\n classdocs\n '''\n\n def __init__(self, language):\n '''\n Constructor", " '''\n classdocs\n '''", " def __init__(self, language):\n '''...
''' Module which compares languague files to the master file and detects issues. @author: Rodrigo Damazio ''' import os from mytracks.parser import StringsParser import mytracks.history class Validator(object): def __init__(self, languages): ''' Builds a strings file validator. Params: @para...
[ [ 8, 0, 0.0304, 0.0522, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.0696, 0.0087, 0, 0.66, 0.25, 688, 0, 1, 0, 0, 688, 0, 0 ], [ 1, 0, 0.0783, 0.0087, 0, 0.66, ...
[ "'''\nModule which compares languague files to the master file and detects\nissues.\n\n@author: Rodrigo Damazio\n'''", "import os", "from mytracks.parser import StringsParser", "import mytracks.history", "class Validator(object):\n\n def __init__(self, languages):\n '''\n Builds a strings file valida...
''' Module for dealing with resource files (but not their contents). @author: Rodrigo Damazio ''' import os.path from glob import glob import re MYTRACKS_RES_DIR = 'MyTracks/res' ANDROID_MASTER_VALUES = 'values' ANDROID_VALUES_MASK = 'values-*' def GetMyTracksDir(): ''' Returns the directory in which the MyTrac...
[ [ 8, 0, 0.0667, 0.1111, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.1333, 0.0222, 0, 0.66, 0.125, 79, 0, 1, 0, 0, 79, 0, 0 ], [ 1, 0, 0.1556, 0.0222, 0, 0.66, ...
[ "'''\nModule for dealing with resource files (but not their contents).\n\n@author: Rodrigo Damazio\n'''", "import os.path", "from glob import glob", "import re", "MYTRACKS_RES_DIR = 'MyTracks/res'", "ANDROID_MASTER_VALUES = 'values'", "ANDROID_VALUES_MASK = 'values-*'", "def GetMyTracksDir():\n '''\n...
''' Module which parses a string XML file. @author: Rodrigo Damazio ''' from xml.parsers.expat import ParserCreate import re #import xml.etree.ElementTree as ET class StringsParser(object): ''' Parser for string XML files. This object is not thread-safe and should be used for parsing a single file at a time...
[ [ 8, 0, 0.0261, 0.0435, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.0609, 0.0087, 0, 0.66, 0.3333, 573, 0, 1, 0, 0, 573, 0, 0 ], [ 1, 0, 0.0696, 0.0087, 0, 0.66...
[ "'''\nModule which parses a string XML file.\n\n@author: Rodrigo Damazio\n'''", "from xml.parsers.expat import ParserCreate", "import re", "class StringsParser(object):\n '''\n Parser for string XML files.\n\n This object is not thread-safe and should be used for parsing a single file at\n a time, only.\n...
#!/usr/bin/python import os def main(): lists = [ "ISODrivers/Galaxy/galaxy.prx", "ISODrivers/March33/march33.prx", "ISODrivers/March33/march33_620.prx", "ISODrivers/Inferno/inferno.prx", "Popcorn/popcorn.prx", "Satelite/satelite.prx", "Stargate/stargate.prx", "SystemControl/systemctrl.prx", ...
[ [ 1, 0, 0.1071, 0.0357, 0, 0.66, 0, 688, 0, 1, 0, 0, 688, 0, 0 ], [ 2, 0, 0.5357, 0.75, 0, 0.66, 0.5, 624, 0, 0, 0, 0, 0, 0, 3 ], [ 14, 1, 0.4286, 0.4643, 1, 0.91, ...
[ "import os", "def main():\n\tlists = [\n\t\t\t\"ISODrivers/Galaxy/galaxy.prx\",\n\t\t\t\"ISODrivers/March33/march33.prx\",\n\t\t\t\"ISODrivers/March33/march33_620.prx\",\n\t\t\t\"ISODrivers/Inferno/inferno.prx\",\n\t\t\t\"Popcorn/popcorn.prx\",\n\t\t\t\"Satelite/satelite.prx\",", "\tlists = [\n\t\t\t\"ISODriver...
#!/usr/bin/python class FakeTime: def time(self): return 1225856967.109 import os, gzip, StringIO gzip.time = FakeTime() def create_gzip(input, output): f_in=open(input, 'rb') temp=StringIO.StringIO() f=gzip.GzipFile(fileobj=temp, mode='wb') f.writelines(f_in) f.close() f_in.close() fout=open(out...
[ [ 3, 0, 0.0909, 0.0682, 0, 0.66, 0, 425, 0, 1, 0, 0, 0, 0, 0 ], [ 2, 1, 0.1023, 0.0455, 1, 0.28, 0, 654, 0, 1, 1, 0, 0, 0, 0 ], [ 13, 2, 0.1136, 0.0227, 2, 0.71, ...
[ "class FakeTime:\n def time(self):\n return 1225856967.109", " def time(self):\n return 1225856967.109", " return 1225856967.109", "import os, gzip, StringIO", "gzip.time = FakeTime()", "def create_gzip(input, output):\n\tf_in=open(input, 'rb')\n\ttemp=StringIO.StringIO()\n\tf=g...
#!/usr/bin/python from hashlib import * import sys, struct def sha512(psid): if len(psid) != 16: return "".encode() for i in range(512): psid = sha1(psid).digest() return psid def get_psid(str): if len(str) != 32: return "".encode() b = "".encode() for i in range(0, len(str), 2): b += struct.pack('B...
[ [ 1, 0, 0.0652, 0.0217, 0, 0.66, 0, 154, 0, 1, 0, 0, 154, 0, 0 ], [ 1, 0, 0.087, 0.0217, 0, 0.66, 0.2, 509, 0, 2, 0, 0, 509, 0, 0 ], [ 2, 0, 0.2065, 0.1739, 0, 0.66...
[ "from hashlib import *", "import sys, struct", "def sha512(psid):\n\tif len(psid) != 16:\n\t\treturn \"\".encode()\n\n\tfor i in range(512):\n\t\tpsid = sha1(psid).digest()\n\n\treturn psid", "\tif len(psid) != 16:\n\t\treturn \"\".encode()", "\t\treturn \"\".encode()", "\tfor i in range(512):\n\t\tpsid =...
#!/usr/bin/python import sys, hashlib def toNID(name): hashstr = hashlib.sha1(name.encode()).hexdigest().upper() return "0x" + hashstr[6:8] + hashstr[4:6] + hashstr[2:4] + hashstr[0:2] if __name__ == "__main__": assert(toNID("sceKernelCpuSuspendIntr") == "0x092968F4") for name in sys.argv[1:]: print ("%s: %s"...
[ [ 1, 0, 0.2308, 0.0769, 0, 0.66, 0, 509, 0, 2, 0, 0, 509, 0, 0 ], [ 2, 0, 0.4615, 0.2308, 0, 0.66, 0.5, 259, 0, 1, 1, 0, 0, 0, 4 ], [ 14, 1, 0.4615, 0.0769, 1, 0.3,...
[ "import sys, hashlib", "def toNID(name):\n\thashstr = hashlib.sha1(name.encode()).hexdigest().upper()\n\treturn \"0x\" + hashstr[6:8] + hashstr[4:6] + hashstr[2:4] + hashstr[0:2]", "\thashstr = hashlib.sha1(name.encode()).hexdigest().upper()", "\treturn \"0x\" + hashstr[6:8] + hashstr[4:6] + hashstr[2:4] + ha...
#!/usr/bin/python """ pspbtcnf_editor: An script that add modules from pspbtcnf """ import sys, os, re from getopt import * from struct import * BTCNF_MAGIC=0x0F803001 verbose = False def print_usage(): print ("%s: pspbtcnf.bin [-o output.bin] [-a add_module_name:before_module_name:flag]" %(os.path...
[ [ 8, 0, 0.022, 0.0165, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.0385, 0.0055, 0, 0.66, 0.0769, 509, 0, 3, 0, 0, 509, 0, 0 ], [ 1, 0, 0.044, 0.0055, 0, 0.66, ...
[ "\"\"\"\npspbtcnf_editor: An script that add modules from pspbtcnf\n\"\"\"", "import sys, os, re", "from getopt import *", "from struct import *", "BTCNF_MAGIC=0x0F803001", "verbose = False", "def print_usage():\n\tprint (\"%s: pspbtcnf.bin [-o output.bin] [-a add_module_name:before_module_name:flag]\" ...
#!/usr/bin/python class FakeTime: def time(self): return 1225856967.109 import sys, os, struct, gzip, hashlib, StringIO gzip.time = FakeTime() def binary_replace(data, newdata, offset): return data[0:offset] + newdata + data[offset+len(newdata):] def prx_compress(output, hdr, input, mod_name="", mod_a...
[ [ 3, 0, 0.0488, 0.0366, 0, 0.66, 0, 425, 0, 1, 0, 0, 0, 0, 0 ], [ 2, 1, 0.0549, 0.0244, 1, 0.6, 0, 654, 0, 1, 1, 0, 0, 0, 0 ], [ 13, 2, 0.061, 0.0122, 2, 0.31, ...
[ "class FakeTime:\n def time(self):\n return 1225856967.109", " def time(self):\n return 1225856967.109", " return 1225856967.109", "import sys, os, struct, gzip, hashlib, StringIO", "gzip.time = FakeTime()", "def binary_replace(data, newdata, offset):\n\treturn data[0:offset] + ...
#!/usr/bin/env python import time t = time.time() u = time.gmtime(t) s = time.strftime('%a, %e %b %Y %T GMT', u) print 'Content-Type: text/javascript' print 'Cache-Control: no-cache' print 'Date: ' + s print 'Expires: ' + s print '' print 'var timeskew = new Date().getTime() - ' + str(t*1000) + ';'
[ [ 1, 0, 0.1818, 0.0909, 0, 0.66, 0, 654, 0, 1, 0, 0, 654, 0, 0 ], [ 14, 0, 0.2727, 0.0909, 0, 0.66, 0.1111, 15, 3, 0, 0, 0, 654, 10, 1 ], [ 14, 0, 0.3636, 0.0909, 0, ...
[ "import time", "t = time.time()", "u = time.gmtime(t)", "s = time.strftime('%a, %e %b %Y %T GMT', u)", "print('Content-Type: text/javascript')", "print('Cache-Control: no-cache')", "print('Date: ' + s)", "print('Expires: ' + s)", "print('')", "print('var timeskew = new Date().getTime() - ' + str(t...
#!/bin/env python import xml.dom.minidom as dom import sys import struct WEAP_NUM = 780 struct_fmt = "<H BBHBBBB 8B8B8b8b8b8b8H bbBBBB" def pack_weapon(dict): l = [] l.append(dict['drain']) l.append(dict['shotRepeat']) l.append(dict['multi']) l.append(dict['weapAni']) l.append(dict['max']) l.append(dict['tx...
[ [ 1, 0, 0.0129, 0.0043, 0, 0.66, 0, 770, 0, 1, 0, 0, 770, 0, 0 ], [ 1, 0, 0.0172, 0.0043, 0, 0.66, 0.0833, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.0215, 0.0043, 0, ...
[ "import xml.dom.minidom as dom", "import sys", "import struct", "WEAP_NUM = 780", "struct_fmt = \"<H BBHBBBB 8B8B8b8b8b8b8H bbBBBB\"", "def pack_weapon(dict):\n\tl = []\n\n\tl.append(dict['drain'])\n\tl.append(dict['shotRepeat'])\n\tl.append(dict['multi'])\n\tl.append(dict['weapAni'])\n\tl.append(dict['ma...
# -*- coding: utf-8 -*- # # jQuery File Upload Plugin GAE Python Example 2.1.0 # https://github.com/blueimp/jQuery-File-Upload # # Copyright 2011, Sebastian Tschan # https://blueimp.net # # Licensed under the MIT license: # http://www.opensource.org/licenses/MIT # from __future__ import with_statement from google.appe...
[ [ 1, 0, 0.0788, 0.0061, 0, 0.66, 0, 777, 0, 1, 0, 0, 777, 0, 0 ], [ 1, 0, 0.0848, 0.0061, 0, 0.66, 0.0556, 279, 0, 2, 0, 0, 279, 0, 0 ], [ 1, 0, 0.0909, 0.0061, 0, ...
[ "from __future__ import with_statement", "from google.appengine.api import files, images", "from google.appengine.ext import blobstore, deferred", "from google.appengine.ext.webapp import blobstore_handlers", "import json", "import re", "import urllib", "import webapp2", "WEBSITE = 'http://blueimp.g...
import socket port = 54321 #host = "137.138.196.188" host="0.0.0.0" UDPsock=socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # Accepte les datagrammes UDP sur le port depuis tous les expediteurs UDPsock.bind((host, port)) #UDPsock.connect(('137.138.196.188',port)) print "Ecoute sur port", port while 1: data, addr =...
[ [ 1, 0, 0.0556, 0.0556, 0, 0.66, 0, 687, 0, 1, 0, 0, 687, 0, 0 ], [ 14, 0, 0.1111, 0.0556, 0, 0.66, 0.1667, 308, 1, 0, 0, 0, 0, 1, 0 ], [ 14, 0, 0.2222, 0.0556, 0, ...
[ "import socket", "port = 54321", "host=\"0.0.0.0\"", "UDPsock=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)", "UDPsock.bind((host, port))", "print(\"Ecoute sur port\", port)", "while 1:\n data, addr = UDPsock.recvfrom(128)\n# print \"Recu:\", data , \"de\", addr\n# print \"Recu:\", data \n ...
import socket,time port = 54321 #host = "localhost" host = "192.168.0.9" #host = "137.138.196.188" #host="128.141.140.144" UDPsock=socket.socket(socket.AF_INET, socket.SOCK_DGRAM) #s.bind(("", port)) while ( 1 ): commande = raw_input("Commande? ") UDPsock.sendto(commande,(host, port)) print "envoie commande...
[ [ 1, 0, 0.0833, 0.0833, 0, 0.66, 0, 687, 0, 2, 0, 0, 687, 0, 0 ], [ 14, 0, 0.1667, 0.0833, 0, 0.66, 0.25, 308, 1, 0, 0, 0, 0, 1, 0 ], [ 14, 0, 0.3333, 0.0833, 0, 0....
[ "import socket,time", "port = 54321", "host = \"192.168.0.9\"", "UDPsock=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)", "while ( 1 ):\n commande = raw_input(\"Commande? \")\n UDPsock.sendto(commande,(host, port))\n print(\"envoie commande[\",commande,\"]\")", " commande = raw_input(\"Comma...
''' Module which brings history information about files from Mercurial. @author: Rodrigo Damazio ''' import re import subprocess REVISION_REGEX = re.compile(r'(?P<hash>[0-9a-f]{12}):.*') def _GetOutputLines(args): ''' Runs an external process and returns its output as a list of lines. @param args: the argume...
[ [ 8, 0, 0.0319, 0.0532, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.0745, 0.0106, 0, 0.66, 0.1429, 540, 0, 1, 0, 0, 540, 0, 0 ], [ 1, 0, 0.0851, 0.0106, 0, 0.66...
[ "'''\nModule which brings history information about files from Mercurial.\n\n@author: Rodrigo Damazio\n'''", "import re", "import subprocess", "REVISION_REGEX = re.compile(r'(?P<hash>[0-9a-f]{12}):.*')", "def _GetOutputLines(args):\n '''\n Runs an external process and returns its output as a list of lines...
#!/usr/bin/python ''' Entry point for My Tracks i18n tool. @author: Rodrigo Damazio ''' import mytracks.files import mytracks.translate import mytracks.validate import sys def Usage(): print 'Usage: %s <command> [<language> ...]\n' % sys.argv[0] print 'Commands are:' print ' cleanup' print ' translate' p...
[ [ 8, 0, 0.0417, 0.0521, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.0833, 0.0104, 0, 0.66, 0.125, 640, 0, 1, 0, 0, 640, 0, 0 ], [ 1, 0, 0.0938, 0.0104, 0, 0.66,...
[ "'''\nEntry point for My Tracks i18n tool.\n\n@author: Rodrigo Damazio\n'''", "import mytracks.files", "import mytracks.translate", "import mytracks.validate", "import sys", "def Usage():\n print('Usage: %s <command> [<language> ...]\\n' % sys.argv[0])\n print('Commands are:')\n print(' cleanup')\n p...
''' Module which prompts the user for translations and saves them. TODO: implement @author: Rodrigo Damazio ''' class Translator(object): ''' classdocs ''' def __init__(self, language): ''' Constructor ''' self._language = language def Translate(self, string_names): print string_names
[ [ 8, 0, 0.1905, 0.3333, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 3, 0, 0.7143, 0.619, 0, 0.66, 1, 229, 0, 2, 0, 0, 186, 0, 1 ], [ 8, 1, 0.5238, 0.1429, 1, 0.75, ...
[ "'''\nModule which prompts the user for translations and saves them.\n\nTODO: implement\n\n@author: Rodrigo Damazio\n'''", "class Translator(object):\n '''\n classdocs\n '''\n\n def __init__(self, language):\n '''\n Constructor", " '''\n classdocs\n '''", " def __init__(self, language):\n '''...
''' Module which compares languague files to the master file and detects issues. @author: Rodrigo Damazio ''' import os from mytracks.parser import StringsParser import mytracks.history class Validator(object): def __init__(self, languages): ''' Builds a strings file validator. Params: @para...
[ [ 8, 0, 0.0304, 0.0522, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.0696, 0.0087, 0, 0.66, 0.25, 688, 0, 1, 0, 0, 688, 0, 0 ], [ 1, 0, 0.0783, 0.0087, 0, 0.66, ...
[ "'''\nModule which compares languague files to the master file and detects\nissues.\n\n@author: Rodrigo Damazio\n'''", "import os", "from mytracks.parser import StringsParser", "import mytracks.history", "class Validator(object):\n\n def __init__(self, languages):\n '''\n Builds a strings file valida...
''' Module for dealing with resource files (but not their contents). @author: Rodrigo Damazio ''' import os.path from glob import glob import re MYTRACKS_RES_DIR = 'MyTracks/res' ANDROID_MASTER_VALUES = 'values' ANDROID_VALUES_MASK = 'values-*' def GetMyTracksDir(): ''' Returns the directory in which the MyTrac...
[ [ 8, 0, 0.0667, 0.1111, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.1333, 0.0222, 0, 0.66, 0.125, 79, 0, 1, 0, 0, 79, 0, 0 ], [ 1, 0, 0.1556, 0.0222, 0, 0.66, ...
[ "'''\nModule for dealing with resource files (but not their contents).\n\n@author: Rodrigo Damazio\n'''", "import os.path", "from glob import glob", "import re", "MYTRACKS_RES_DIR = 'MyTracks/res'", "ANDROID_MASTER_VALUES = 'values'", "ANDROID_VALUES_MASK = 'values-*'", "def GetMyTracksDir():\n '''\n...
''' Module which parses a string XML file. @author: Rodrigo Damazio ''' from xml.parsers.expat import ParserCreate import re #import xml.etree.ElementTree as ET class StringsParser(object): ''' Parser for string XML files. This object is not thread-safe and should be used for parsing a single file at a time...
[ [ 8, 0, 0.0261, 0.0435, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.0609, 0.0087, 0, 0.66, 0.3333, 573, 0, 1, 0, 0, 573, 0, 0 ], [ 1, 0, 0.0696, 0.0087, 0, 0.66...
[ "'''\nModule which parses a string XML file.\n\n@author: Rodrigo Damazio\n'''", "from xml.parsers.expat import ParserCreate", "import re", "class StringsParser(object):\n '''\n Parser for string XML files.\n\n This object is not thread-safe and should be used for parsing a single file at\n a time, only.\n...
# # Secret Labs' Regular Expression Engine # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # This version of the SRE library can be redistributed under CNRI's # Python 1.6 license. For any other use, please contact Secret Labs # AB (info@pythonware.com). # # Portions of this engine have been dev...
[ [ 8, 0, 0.1657, 0.2873, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 14, 0, 0.3172, 0.01, 0, 0.66, 0.0238, 272, 0, 0, 0, 0, 0, 5, 0 ], [ 14, 0, 0.3243, 0.0014, 0, 0.66, ...
[ "r\"\"\"Support for regular expressions (RE).\n\nThis module provides regular expression matching operations similar to those\nfound in Perl. It supports both 8-bit and Unicode strings; both the pattern and\nthe strings being processed can contain null bytes and characters outside the\nUS ASCII range.\n\nRegular ex...
# # Secret Labs' Regular Expression Engine core module # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # This version of the SRE library can be redistributed under CNRI's # Python 1.6 license. For any other use, please contact Secret Labs # AB (info@pythonware.com). # # Portions of this engine h...
[ [ 1, 0, 0.0039, 0.0002, 0, 0.66, 0, 890, 0, 1, 0, 0, 890, 0, 0 ], [ 1, 0, 0.0041, 0.0002, 0, 0.66, 0.0052, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.0044, 0.0002, 0, ...
[ "import string", "import sys", "import unicodedata", "from collections import defaultdict", "import _regex", "__all__ = [\"A\", \"ASCII\", \"B\", \"BESTMATCH\", \"D\", \"DEBUG\", \"E\", \"ENHANCEMATCH\",\n \"F\", \"FULLCASE\", \"I\", \"IGNORECASE\", \"L\", \"LOCALE\", \"M\", \"MULTILINE\", \"R\",\n \"RE...
# # Secret Labs' Regular Expression Engine # # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved. # # This version of the SRE library can be redistributed under CNRI's # Python 1.6 license. For any other use, please contact Secret Labs # AB (info@pythonware.com). # # Portions of this engine have been dev...
[ [ 8, 0, 0.1701, 0.2949, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 14, 0, 0.3255, 0.0102, 0, 0.66, 0.0244, 272, 0, 0, 0, 0, 0, 5, 0 ], [ 14, 0, 0.3328, 0.0015, 0, 0.66...
[ "r\"\"\"Support for regular expressions (RE).\n\nThis module provides regular expression matching operations similar to those\nfound in Perl. It supports both 8-bit and Unicode strings; both the pattern and\nthe strings being processed can contain null bytes and characters outside the\nUS ASCII range.\n\nRegular ex...
#!/usr/bin/env python import os import sys from distutils.core import setup, Extension MAJOR, MINOR = sys.version_info[:2] BASE_DIR = os.path.dirname(os.path.abspath(__file__)) PKG_BASE = 'Python%i' % MAJOR DOCS_DIR = os.path.join(BASE_DIR, 'docs') setup( name='regex', version='2014.12.24', description...
[ [ 1, 0, 0.0577, 0.0192, 0, 0.66, 0, 688, 0, 1, 0, 0, 688, 0, 0 ], [ 1, 0, 0.0769, 0.0192, 0, 0.66, 0.1429, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.1154, 0.0192, 0, ...
[ "import os", "import sys", "from distutils.core import setup, Extension", "MAJOR, MINOR = sys.version_info[:2]", "BASE_DIR = os.path.dirname(os.path.abspath(__file__))", "PKG_BASE = 'Python%i' % MAJOR", "DOCS_DIR = os.path.join(BASE_DIR, 'docs')", "setup(\n name='regex',\n version='2014.12.24',\...
#!/usr/bin/python # Copyright 2011 Google, Inc. All Rights Reserved. # simple script to walk source tree looking for third-party licenses # dumps resulting html page to stdout import os, re, mimetypes, sys # read source directories to scan from command line SOURCE = sys.argv[1:] # regex to find /* */ style commen...
[ [ 1, 0, 0.0816, 0.0102, 0, 0.66, 0, 688, 0, 4, 0, 0, 688, 0, 0 ], [ 14, 0, 0.1224, 0.0102, 0, 0.66, 0.0714, 792, 6, 0, 0, 0, 0, 0, 0 ], [ 14, 0, 0.1531, 0.0102, 0, ...
[ "import os, re, mimetypes, sys", "SOURCE = sys.argv[1:]", "COMMENT_BLOCK = re.compile(r\"(/\\*.+?\\*/)\", re.MULTILINE | re.DOTALL)", "COMMENT_LICENSE = re.compile(r\"(license)\", re.IGNORECASE)", "COMMENT_COPYRIGHT = re.compile(r\"(copyright)\", re.IGNORECASE)", "EXCLUDE_TYPES = [\n \"application/xml\...
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright 2012 Zdenko Podobný # Author: Zdenko Podobný # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LIC...
[ [ 1, 0, 0.25, 0.25, 0, 0.66, 0, 688, 0, 1, 0, 0, 688, 0, 0 ], [ 1, 0, 0.5, 0.25, 0, 0.66, 0.5, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 1, 0, 0.75, 0.25, 0, 0.66, 1, ...
[ "import os", "import sys", "import ctypes" ]
''' Created on Feb 3, 2013 @author: bawey ''' import cpoo_tools as tools import cv import cv2 import numpy as np import sys import tesseract from cpoo_tools import show_wait image = cv.LoadImage( sys.argv[1] ) image = tools.split_channels( image ) resized = cv.CreateImage( ( ( int )( image.width * ( 640.0 / image...
[ [ 8, 0, 0.0588, 0.098, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.1569, 0.0196, 0, 0.66, 0.0417, 991, 0, 1, 0, 0, 991, 0, 0 ], [ 1, 0, 0.1765, 0.0196, 0, 0.66,...
[ "'''\nCreated on Feb 3, 2013\n\n@author: bawey\n'''", "import cpoo_tools as tools", "import cv", "import cv2", "import numpy as np", "import sys", "import tesseract", "from cpoo_tools import show_wait", "image = cv.LoadImage( sys.argv[1] )", "image = tools.split_channels( image )", "resized = cv...
import cv2 import cv import sys import cpoo_tools as tools import numpy as np image = cv.LoadImage( sys.argv[1] ) # tools.grow_region(image) # TODO: set radius dynamically img = cv.CreateImage( cv.GetSize( image ), image.depth, image.nChannels ) img = tools.split_channels( image ) img = tools.array2cv( cv2.Gaussian...
[ [ 1, 0, 0.0256, 0.0256, 0, 0.66, 0, 896, 0, 1, 0, 0, 896, 0, 0 ], [ 1, 0, 0.0513, 0.0256, 0, 0.66, 0.0526, 492, 0, 1, 0, 0, 492, 0, 0 ], [ 1, 0, 0.0769, 0.0256, 0, ...
[ "import cv2", "import cv", "import sys", "import cpoo_tools as tools", "import numpy as np", "image = cv.LoadImage( sys.argv[1] )", "img = cv.CreateImage( cv.GetSize( image ), image.depth, image.nChannels )", "img = tools.split_channels( image )", "img = tools.array2cv( cv2.GaussianBlur( tools.cv2ar...
"""OCR in Python using the Tesseract engine from Google http://code.google.com/p/pytesser/ by Michael J.T. O'Kelly V 0.0.1, 3/10/07""" import Image import subprocess import util import errors tesseract_exe_name = 'tesseract' # Name of executable to be called at command line scratch_image_name = "temp.bmp...
[ [ 1, 0, 0.0213, 0.0213, 0, 0.66, 0, 721, 0, 1, 0, 0, 721, 0, 0 ], [ 1, 0, 0.0426, 0.0213, 0, 0.66, 0.1667, 394, 0, 1, 0, 0, 394, 0, 0 ], [ 1, 0, 0.0851, 0.0213, 0, ...
[ "import Image", "import subprocess", "import util", "import errors", "def call_tesseract(input_filename, output_filename):\n\t\"\"\"Calls external tesseract.exe on input file (restrictions on types),\n\toutputting output_filename+'txt'\"\"\"\n\targs = [tesseract_exe_name, input_filename, output_filename]\n\...
import cv2 import cv import sys import cpoo_tools as tools import pylab import numpy as np img = cv.LoadImage(sys.argv[1]) #img = cv.LoadImage("meat/rgb.png") # eig_image = cv.CreateMat(img.rows, img.cols, cv2.CV_32FC1) # temp_image = cv.CreateMat(img.rows, img.cols, cv2.CV_32FC1) # for (x,y) in cv.GoodFeaturesToTrack...
[ [ 1, 0, 0.0065, 0.0065, 0, 0.66, 0, 896, 0, 1, 0, 0, 896, 0, 0 ], [ 1, 0, 0.0131, 0.0065, 0, 0.66, 0.0244, 492, 0, 1, 0, 0, 492, 0, 0 ], [ 1, 0, 0.0196, 0.0065, 0, ...
[ "import cv2", "import cv", "import sys", "import cpoo_tools as tools", "import pylab", "import numpy as np", "img = cv.LoadImage(sys.argv[1])", "print(\"height: \"+str(img.height))", "print(\"width: \"+str(img.width))", "print(type(img))", "red = cv.CreateImage(cv.GetSize(img), img.depth, 1)", ...
import cv import cv2 import numpy as np import collections def extract( image, region ): histogram = dict() imgcp = cv.CreateImage( cv.GetSize( image ), image.depth, image.nChannels ) cv.Copy( image, imgcp ) for pixel in region: color = imgcp[pixel[1], pixel[0]] if color not in histogra...
[ [ 1, 0, 0.0022, 0.0022, 0, 0.66, 0, 492, 0, 1, 0, 0, 492, 0, 0 ], [ 1, 0, 0.0045, 0.0022, 0, 0.66, 0.0286, 896, 0, 1, 0, 0, 896, 0, 0 ], [ 1, 0, 0.0067, 0.0022, 0, ...
[ "import cv", "import cv2", "import numpy as np", "import collections", "def extract( image, region ):\n histogram = dict()\n imgcp = cv.CreateImage( cv.GetSize( image ), image.depth, image.nChannels )\n cv.Copy( image, imgcp )\n for pixel in region:\n color = imgcp[pixel[1], pixel[0]]\n ...
import tesseract import sys api = tesseract.TessBaseAPI() api.Init(".","eng",tesseract.OEM_DEFAULT) api.SetVariable("tessedit_char_whitelist", "0123456789\.\:") api.SetPageSegMode(tesseract.PSM_AUTO) mImgFile = sys.argv[1] mBuffer=open(mImgFile,"rb").read() result = tesseract.ProcessPagesBuffer(mBuffer,len(mBuffer),a...
[ [ 1, 0, 0.0833, 0.0833, 0, 0.66, 0, 332, 0, 1, 0, 0, 332, 0, 0 ], [ 1, 0, 0.1667, 0.0833, 0, 0.66, 0.1111, 509, 0, 1, 0, 0, 509, 0, 0 ], [ 14, 0, 0.3333, 0.0833, 0, ...
[ "import tesseract", "import sys", "api = tesseract.TessBaseAPI()", "api.Init(\".\",\"eng\",tesseract.OEM_DEFAULT)", "api.SetVariable(\"tessedit_char_whitelist\", \"0123456789\\.\\:\")", "api.SetPageSegMode(tesseract.PSM_AUTO)", "mImgFile = sys.argv[1]", "mBuffer=open(mImgFile,\"rb\").read()", "resul...
"""Utility functions for processing images for delivery to Tesseract""" import os def image_to_scratch(im, scratch_image_name): """Saves image in memory to scratch file. .bmp format will be read correctly by Tesseract""" im.save(scratch_image_name, dpi=(200,200)) def retrieve_text(scratch_text_name_root):...
[ [ 8, 0, 0.0476, 0.0476, 0, 0.66, 0, 0, 1, 0, 0, 0, 0, 0, 0 ], [ 1, 0, 0.1429, 0.0476, 0, 0.66, 0.25, 688, 0, 1, 0, 0, 688, 0, 0 ], [ 2, 0, 0.2857, 0.1429, 0, 0.66, ...
[ "\"\"\"Utility functions for processing images for delivery to Tesseract\"\"\"", "import os", "def image_to_scratch(im, scratch_image_name):\n\t\"\"\"Saves image in memory to scratch file. .bmp format will be read correctly by Tesseract\"\"\"\n\tim.save(scratch_image_name, dpi=(200,200))", "\t\"\"\"Saves ima...
import cv2 import numpy as np img = cv2.imread('meat/551054_346968652052693_986626722_n.jpg') h = np.zeros((300,256,3)) bins = np.arange(256).reshape(256,1) color = [ (255,0,0),(0,255,0),(0,0,255) ] for ch, col in enumerate(color): hist_item = cv2.calcHist([img],[ch],None,[256],[0,255]) cv2.normalize(hist_i...
[ [ 1, 0, 0.0526, 0.0526, 0, 0.66, 0, 896, 0, 1, 0, 0, 896, 0, 0 ], [ 1, 0, 0.1053, 0.0526, 0, 0.66, 0.1111, 954, 0, 1, 0, 0, 954, 0, 0 ], [ 14, 0, 0.2105, 0.0526, 0, ...
[ "import cv2", "import numpy as np", "img = cv2.imread('meat/551054_346968652052693_986626722_n.jpg')", "h = np.zeros((300,256,3))", "bins = np.arange(256).reshape(256,1)", "color = [ (255,0,0),(0,255,0),(0,0,255) ]", "for ch, col in enumerate(color):\n hist_item = cv2.calcHist([img],[ch],None,[256],[...
from PIL import Image import ImageEnhance from pytesser import * from urllib import urlretrieve import sys im = Image.open(sys.argv[1]) nx, ny = im.size im2 = im.resize((int(nx*5), int(ny*5)), Image.BICUBIC) im2.save("temp2.png") enh = ImageEnhance.Contrast(im) enh.enhance(1.3).show("30% more contrast") imgx = Im...
[ [ 1, 0, 0.0357, 0.0357, 0, 0.66, 0, 556, 0, 1, 0, 0, 556, 0, 0 ], [ 1, 0, 0.0714, 0.0357, 0, 0.66, 0.0476, 573, 0, 1, 0, 0, 573, 0, 0 ], [ 1, 0, 0.1071, 0.0357, 0, ...
[ "from PIL import Image", "import ImageEnhance", "from pytesser import *", "from urllib import urlretrieve", "import sys", "im = Image.open(sys.argv[1])", "nx, ny = im.size", "im2 = im.resize((int(nx*5), int(ny*5)), Image.BICUBIC)", "im2.save(\"temp2.png\")", "enh = ImageEnhance.Contrast(im)", "e...