This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
f = open("enable1.txt") | |
words = [x.strip().upper() for x in f.readlines()] | |
def CreateWords(difficulty=1): | |
"""Take the difficulty number and a list of words, return | |
a list of words accordingly""" | |
newwords = [] | |
i = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import sys | |
import praw | |
# ========================================== | |
# ===============Configuration============== | |
user = 'dogetipbot' | |
# ========================================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import time | |
import sys | |
import praw | |
# ========================================== | |
# ===============Configuration============== | |
user_to_reply_to = 'echocage' | |
messages = ['examplecomment1', "Example Comment 2"] | |
username = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = r"""File Name : File1.txt | |
Directory : Path\to\File1.txt | |
Created : 2012:04:15 10:15:32 | |
Accessed : 2012:04:18 13:28:18""" | |
items = [] | |
for line in data.split('\n'): | |
type = line.split(':')[0].strip() | |
rest = ':'.join(map(lambda x: x.strip(), line.split(':')[1:])) | |
if type == 'File Name': | |
items.append({type: rest}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
whitelisted_users = map(lambda x: x.strip('\n'), list(open('users'))) | |
whitelisted_domains = map(lambda x: x.strip('\n'), list(open('domains'))) | |
import praw | |
import time | |
import traceback | |
# ========================================== | |
# ===============Configuration============== | |
username = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import urllib2 | |
stages = [["O"], ["O", "|"], [" O", "/|"], [" O", "/|\\"], [" O", " /|\\", " /"], [" O", "/|\\", "/ \\"]] | |
words = urllib2.urlopen('http://pastebin.com/raw.php?i=1nCnmv2y').readlines() | |
words = map(lambda x: x.strip(), words) | |
words.sort(key=lambda x: len(x)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calchar = ("o", "i", "z", "e", "h", "s", "g", "l", "b", "g") | |
wordlist = [] | |
with open("dictionary.txt") as f: | |
with open("newdict.txt", 'w') as output_file: | |
for line in f: | |
if all(c in calchar for c in line): | |
output_file.write(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_next_prime(n): | |
while True: | |
n += 1 | |
prime = isPrime(n) | |
if prime: | |
return n | |
def isPrime(n): | |
for item in xrange(2, n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import time | |
while True: | |
with open('filename.txt', 'w+') as output: | |
now = datetime.datetime.now().time().strftime('%I:%M:%S') | |
output.write(now) | |
time.sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assignments | |
### *mutability | |
What's the difference between a mutable and an immutable type? Why should I use one or the other? Write the following two functions, both receiving a list of elements and a new elemnt to append at the end. The first one should be a mutable version and the second an immutable version. | |
Example mutable: | |
l = [1, 2, 3] | |
mutable_append(l, 'a') |
OlderNewer