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
# Exercise completed as part of Erin Allard's Lynda.com course, | |
# 'Python Data Structures: Stacks, Queues, and Deques' | |
class Queue: | |
"""An ADT that stores items in the order in which they | |
were added. Items are added to the back and removed | |
from the front - FIFO. | |
""" | |
def __init__(self): | |
self.items = [] |
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
# Exercise completed as part of Erin Allard's Lynda.com course, | |
# 'Python Data Structures: Stacks, Queues, and Deques' | |
class Stack: | |
"""An ADT that stores items in the order in which they were | |
added. Items are added to and removed from the top of the | |
stack - LIFO. | |
""" | |
def __init__(self): | |
self.items = [] |
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
# Screen scraping information from Weather Underground at https://www.wunderground.com/ is for | |
# example purposes only. Try the Weather Underground API at https://www.wunderground.com/weather/api | |
# Project adapted from Michael Kennedy's Python Jumpstart by Building 10 Apps course | |
# Standard Library | |
from collections import namedtuple | |
# Third Party | |
import requests | |
from bs4 import BeautifulSoup |
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 smtplib | |
import ssl | |
from email.mime.text import MIMEText | |
sender = "sender@gmail.com" | |
receiver = "recipient@domain.com" | |
password = input("Enter password: ") | |
text = """\ | |
Hi! |
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
# Learn more about the ICNDb API at: http://www.icndb.com/api/ | |
# Learn more about the Requests library at: http://docs.python-requests.org/en/master/ | |
import requests | |
def get_joke(): | |
"""fetches and prints a random joke""" | |
url = "http://api.icndb.com/jokes/random" | |
resp = requests.get(url) | |
resp.encoding = "utf-8" |
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
# To start, set up a Google form that collects | |
# first name, last name, and email address from participants, | |
# then export as a CSV file and store it in the same | |
# directory as this program | |
# also, enable less secure apps in gmail before running | |
# https://support.google.com/accounts/answer/6010255?hl=en | |
import csv | |
import smtplib | |
from random import shuffle |
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
# Stopwatch recipe taken from Python Cookbook, 3rd Edition, by David Beazley and Brian K. Jones. | |
# Page 561: "As a general rule of thumb, the accuracy of timing measurements made with functions | |
# such as time.time() or time.clock() varies according to the operation system. In contast, | |
# time.perf_counter() always uses the highest-resolution timer available on the system." | |
import time | |
class Timer: | |
def __init__(self, func=time.perf_counter): | |
self.elapsed = 0.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 csv | |
from datetime import datetime | |
from collections import OrderedDict | |
import matplotlib.pyplot as plt | |
# set up empty containers | |
total = 0 | |
months = dict() | |
# open and read CSV |
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 csv | |
from statistics import mean | |
# set up empty dict containers | |
associate_type = dict() # row 6 | |
associate_from = dict() # row 7 | |
maths = dict() # row 14 | |
advisors = dict() # row 15 | |
# set up empty list containers |
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 picamera import PiCamera, Color | |
from time import sleep | |
from datetime import datetime as dt | |
with PiCamera() as camera: | |
camera.rotation = 180 # omit or use 90, 180, 270 depending on setup | |
camera.annotate_background = Color("black") | |
start = dt.now() | |
camera.start_preview() |