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 modules | |
import re | |
def sort_streets(street_list): | |
""" | |
Sort streets alphabetically, ignoring cardinal direction prefixes such as North, South, East and West | |
:param street_list: list of street names | |
""" | |
prefix = re.compile('^North|South|East|West|N\.?|S\.?|E\.?|W\.$', re.IGNORECASE) |
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 | |
class MontyHall: | |
def __init__(self): | |
self._prize_door = random.randint(1,3) | |
self._selected_door = random.randint(1,3) | |
self._removed_door = self.remove_door() | |
def remove_door(self): | |
doors = [1,2,3] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 | |
def msg(room): | |
if room['msg'] == '': #There is no custom message | |
return "You have entered the " + room['name'] + '.' | |
else: | |
return room['msg'] | |
def get_choice(room,dir): | |
if dir=='N': |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 requests | |
from bs4 import BeautifulSoup | |
sitemap = 'http://www.nasa.gov/sitemap/sitemap_nasa.html' | |
r = requests.get(sitemap) | |
html = r.content | |
soup = BeautifulSoup(html, 'html.parser') | |
links = soup.find_all('a') |
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
from bs4 import BeautifulSoup | |
import requests | |
import pandas as pd | |
url = "https://www.akc.org/reg/dogreg_stats.cfm" | |
r = requests.get(url) | |
data = r.text | |
soup = BeautifulSoup(data, "lxml") |
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 os, re | |
dir = 'path-to-your-directory' | |
i=0 | |
results = [] #Store changed files so you can look into it later | |
for dirname, dirnames, filenames in os.walk(dir): | |
for filename in filenames: | |
ext = filename.split('.')[-1] #Get Extension | |
if ext in ('cfc','cfm'): #Limit search to specific file types |
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
""" | |
Creates readable text file from SRT file. | |
""" | |
import re, sys | |
def is_time_stamp(l): | |
if l[:2].isnumeric() and l[2] == ':': | |
return True | |
return False |
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
# based on https://youtu.be/w4wkCcsWs4c | |
def guess_numbers(num1, num2): | |
nums = [num1, num1+10, num1+20, num1+30, | |
num2, num2+10, num2+20, num2+30] | |
return nums | |
def main(): | |
print('''The first step is to find the "Sticky number" | |
by applying pressure to the shackle and turning clockwise |
OlderNewer