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 math | |
class Hexagon: | |
def __init__ (self, side): | |
self.perimeter = (side*6) | |
self.side = side | |
hex1 = Hexagon(16) | |
print (hex1.perimeter) |
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 | |
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"]) | |
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
""" | |
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 |
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
""" | |
Author: Patrick Elward | |
Date: 05/06/2019 | |
continued testing of classes | |
""" | |
class MyClass: | |
def __init__(self): | |
print('object ',self,' constructed') |
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
""" | |
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 |
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
""" | |
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 |
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
""" | |
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 | |
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
""" | |
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 |
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
""" | |
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 | |
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
""" | |
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 |
NewerOlder