Skip to content

Instantly share code, notes, and snippets.

@dumpmycode
dumpmycode / wordcount.py
Last active March 23, 2016 04:36
Google Python class - wordcount.py
#!/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
@dumpmycode
dumpmycode / string2.py
Created March 21, 2016 23:38
Google Python class basic string
#!/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/
# Additional basic string exercises
@dumpmycode
dumpmycode / list1.py
Created March 21, 2016 23:38
Google Python class basic 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/
# Basic list exercises
# Fill in the code for the functions below. main() is already set up
@dumpmycode
dumpmycode / string1.py
Created March 21, 2016 03:33
Google Python Class
#!/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/
# Basic string exercises
# Fill in the code for the functions below. main() is already set up
@dumpmycode
dumpmycode / pexpect.py
Created March 19, 2016 13:06
ViolentPython - pexpect practice
#! /usr/bin/env python
# author: oscarp
# pexpect practice
import pexpect
PROMPT = ['# ', '>>> ', '> ', '\$ ']
def send_command(child, cmd):
child.sendline(cmd)
@dumpmycode
dumpmycode / pwgen.py
Last active August 13, 2016 04:41
practicepython.org - password generator
#! /usr/bin/env python
# author: oscarp
# practicepython.org password generator
import random
import string
def pwgen(pwlen):
box = string.ascii_letters + '][?/<~\#`!@$%^&*()+=}|:";\',>{'
@dumpmycode
dumpmycode / fibo.py
Last active March 2, 2016 07:43
pythonpractice.org - list comprehension(fibonacci numbers)
#! /usr/bin/env python
def fibo(num):
b = [0,1] #seed list with 0,1
[b.append(b[i]+b[i+1]) for i in range(num)]
print b
fibo(int(raw_input('enter a number: ')))
@dumpmycode
dumpmycode / JanKenPon.py
Last active February 26, 2016 07:03
practicepython.org - Rock Paper Scissor single player game
#! /usr/bin/env python
# Author: OscarP
# A single player jankenpon game using randint to generate computer's hand.
# Please feel free to revise.
from random import randint
def convert(choice):
if choice == '1':
return 'rock'
@dumpmycode
dumpmycode / palindrome.py
Created February 25, 2016 13:27
practicepython.org - palindrome.py
#! /usr/bin/env python
def pali(data, word):
for index in range(data):
if word[index] != word[len(word)-(index+1)]:
print('{} is not palindrome.'.format(word))
exit(0)
print('{} is palindrome.'.format(word))
def check(word):