Skip to content

Instantly share code, notes, and snippets.

View chicagowebmanagement's full-sized avatar

Patrick Elward chicagowebmanagement

View GitHub Profile
import math
class Hexagon:
def __init__ (self, side):
self.perimeter = (side*6)
self.side = side
hex1 = Hexagon(16)
print (hex1.perimeter)
@chicagowebmanagement
chicagowebmanagement / write-test.py
Last active August 21, 2019 16:41
testing of Ryan Elam's code
import csv
with open("testingme.csv","w") as csvfile:
write=csv.writer(csvfile, delimiter=",")
write.writerow (["Top Gun", "Risky Business", "Minority Report"])
write.writerow (["Titanic", "The Revenant", "Inception"])
@chicagowebmanagement
chicagowebmanagement / error-classes-review.py
Last active May 14, 2019 23:27
trying to understand classes better
"""
ERRORS
A. print(Triangle.mytriangle_area(self)) = NameError: name 'self' is not defined
B. print(Triangle.mytriangle_area()) = TypeError: mytriangle_area() missing 1 required positional argument: 'self' (SEE LINE with comments BELOW)
C. print(Triangle.mytriangle_area) = prints out '<function Triangle.mytriangle_area at 0x7f8f1a5fb620>'
"""
# ----------------------------------------------
import math
@chicagowebmanagement
chicagowebmanagement / myclass.py
Last active May 15, 2019 00:00
quick testing of class
"""
Author: Patrick Elward
Date: 05/06/2019
continued testing of classes
"""
class MyClass:
def __init__(self):
print('object ',self,' constructed')
@chicagowebmanagement
chicagowebmanagement / rectangle-square-testing.py
Last active May 3, 2019 17:11
create classes and execute them
"""
Author: Patrick Elward
Date: 05/03/2019
Create Rectangle and Square classes with a method called calculate_perimeter that calculates the perimeter of the shapes they represent.
Create Rectangle and Square objects and call the method on both of them.
"""
import math
@chicagowebmanagement
chicagowebmanagement / rectangle-square.py
Last active May 20, 2019 16:35
Create two classes, rectange and square and display the perimeter of each
"""
Author: Patrick Elward
Date: 04/28/2019
Create Rectangle and Square classes with a method called calculate_perimeter that calculates the perimeter of the shapes they represent.
Create Rectangle and Square objects and call the method on both of them.
"""
import math
@chicagowebmanagement
chicagowebmanagement / hexagon.py
Last active April 29, 2019 00:49
Create a hexagon class and calculate its area
"""
Author: Patrick Elward
Date: 04/28/2019
Make a Hexagon class with a method called calculate_perimeter that calculates and returns its perimeter.
Then create a Hexagon object, call calculate_perimeter on it, and print the result.
"""
import math
@chicagowebmanagement
chicagowebmanagement / triangle-sunday.py
Created April 29, 2019 00:13
create a class triangle and return its area
"""
Author: Patrick Elward
Date: 04/28/2019
Create a Triangle class with a method called area that calculates and returns its area.
Then create a Triangle object, call area on it, and print the result.
"""
import math
@chicagowebmanagement
chicagowebmanagement / circle-sunday.py
Created April 29, 2019 00:02
class circle and display area for a given input radius
"""
Author: Patrick Elward
Date: 04/28/2019
. 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.
"""
import math
@chicagowebmanagement
chicagowebmanagement / circle-2.py
Last active April 29, 2019 00:42
create a simple circle and output the area
"""
Author: Patrick Elward
Date: 04/26/2019
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.
import math