This file contains hidden or 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
from collections import Counter | |
import praw | |
import time | |
female_indicators = ["I", "me", "my", "mine", "myself", "you", "your", "yours", "yourself", "she", "her", "hers", | |
"herself"] | |
male_indicators = ["we", "us", "they", "them", "he", "him", "his", "himself"] | |
def calculate_gender(comment_text): |
This file contains hidden or 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
class Animal(object): | |
def __init__(self, name, height, weight, sound): | |
self.name = name | |
self.sound = sound | |
self.weight = weight | |
self.height = height | |
def __str__(self): | |
return "{} is {} cm height {} lbs weight and says {}".format(self.name, self.height, self.weight, | |
self.sound) |
This file contains hidden or 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 os | |
import argparse | |
import sys | |
from sh import rsync | |
parser = argparse.ArgumentParser() | |
parser.add_argument("BACKUPDIR", help="Specify the directory to backup.") | |
parser.add_argument("DESTINATIONDIR", help="Specify the directory where the backup is stored.") | |
args = parser.parse_args() |
This file contains hidden or 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 java.io.BufferedReader; | |
import java.io.FileNotFoundException; | |
import java.io.FileReader; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
public class parser { | |
public static Integer[] getId(String nameGoal) { | |
ArrayList<Integer> ids = new ArrayList<Integer>(); | |
try { |
This file contains hidden or 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 traceback | |
import datetime | |
import praw | |
import time | |
from PasswordManager import pswds | |
r = praw.Reddit('Responds to forgetful OPs in /r/DrunkOrAKid' | |
'by /u/echocage') | |
r.login(username='BecauseOPForgot', password=pswds['BecauseOPForgot']) |
This file contains hidden or 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
class Chair(object): | |
"""Individual chair within the aircraft""" | |
def __init__(self, price=25): | |
self.price = price | |
self.occupied = False | |
def purchase(self): | |
self.occupied = True |
This file contains hidden or 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') |
This file contains hidden or 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 hidden or 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 hidden or 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) |