Skip to content

Instantly share code, notes, and snippets.

View chicagowebmanagement's full-sized avatar

Patrick Elward chicagowebmanagement

View GitHub Profile
@chicagowebmanagement
chicagowebmanagement / triangle-class.py
Last active October 2, 2019 22:47
create a class triangle and get its area.
"""
Author: Patrick Elward
Date: 10/02/2019
training on OOP with getting area of triangle.
THIS WAS NOT WORKING RIGHT in april, but i came back to fix it!
"""
@chicagowebmanagement
chicagowebmanagement / employee-class.py
Last active April 24, 2019 02:49
create a class of Employee and populate with a few workers
"""
Author: Patrick Elward
Date: 04/23/2019
extra curricular study of OOP Classes via Corey Schafer on YouTube.
"""
"""
Author: Patrick Elward
Date: 04/22/2019
revised RPS per Cory's request to A. move code into functions and B. clean up comparison code.
"""
import random
@chicagowebmanagement
chicagowebmanagement / circle-class.py
Last active April 23, 2019 01:15
2. Create a Circle class with a method called area that calculates and returns its area. Then create a Circle object, call area on it, and print the result. Use Python's pi function in the built-in math module.
"""
Author: Patrick Elward
Date: 04/22/2019
2. Create a Circle class with a
method called area that calculates and returns its area.
Then create a Circle object,
call area on it
print the result.
Use Python's pi function in the built-in math module.
@chicagowebmanagement
chicagowebmanagement / four-apples.py
Created April 22, 2019 18:20
define a class called Apple with four instance variables that represent four attributes of an apple.
"""
Author: Patrick Elward
Date: 04/22/2019
1. Define a class called Apple with four instance variables that represent four attributes of an apple.
"""
class Apple:
def __init__(self,c,f,v,h):
self.color=c
self.farm=f
@chicagowebmanagement
chicagowebmanagement / rock-paper-scissors5.py
Last active April 20, 2019 19:47
rock, paper, scissors game
import random
## store our random RPS values as list
weapons = ["rock", "paper", "scissors"]
playtime='y'
while playtime == "y":
playtime=input("Want to play Rock, Paper, Scissors? If Yes, hit y, if No, hit n ")
@chicagowebmanagement
chicagowebmanagement / rock-paper-scissors.py
Last active April 20, 2019 17:15
rock-paper-scissors game
"""
Author: Patrick Elward
Date: 04/20/2019
Rock Paper Scissors game
import random
## store our randon RPS values as list
weapons = ["Rock", "Paper", "Scissors"]
@chicagowebmanagement
chicagowebmanagement / hangmanlist.py
Created April 19, 2019 15:28
modify hangman game to choose from a list
import random
def hangman(word):
wrong = 0
stages = ["",
"________ ",
"| ",
"| | ",
"| 0 ",
"| /|\ ",
@chicagowebmanagement
chicagowebmanagement / flicks.py
Last active May 2, 2019 15:27
create a csv from within python list of lists
"""
Author: Patrick Elward
Date: 04/18/2019
Take the items in this list of lists: [["Top Gun", "Risky Business", "Minority Report"], ["Titanic",
"The Revenant", "Inception"], ["Training Day", "Man on Fire", "Flight"]] and write them to a CSV file.
The data from each list should be a row in the file, with each item in the list separated by a comma.
flicks.csv then shows this:
Top Gun,Risky Business,Minority Report
@chicagowebmanagement
chicagowebmanagement / spanish-inquisition.py
Created April 17, 2019 13:58
ask user question and append to file
"""
Author: Patrick Elward
Date: 04/17/2019
Write a program that asks a user a question, and saves their answer to a file.
"""
with open("spanish_inquisition.txt","a+") as f:
tick=input("what is the time right now?: ")