diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..928c479 Binary files /dev/null and b/.DS_Store differ diff --git a/DSA_homework2.pdf b/DSA_homework2.pdf new file mode 100644 index 0000000..c3d12c8 Binary files /dev/null and b/DSA_homework2.pdf differ diff --git a/DS_A_Assignment_2.pdf b/DS_A_Assignment_2.pdf new file mode 100644 index 0000000..6989f07 Binary files /dev/null and b/DS_A_Assignment_2.pdf differ diff --git a/circle.py b/circle.py new file mode 100644 index 0000000..1b0f699 --- /dev/null +++ b/circle.py @@ -0,0 +1,34 @@ +# create helper functions for simple circular geometry calculations + +from math import pi + +class Circle: + def __init__ (self, radius): + self.radius = radius + + def circle_calculation(self, operation:str) -> float: + """"" + Calculates perimeter/area of circle with given radius. + + Parameters: + radius (float): radius of given circle + + Returns: + float: The perimeter/area of the circle. + """"" + if not isinstance(self.radius, (int, float)): + return "Cannot perform operation with this input" + + if self.radius < 0: + return "Invalid input for radius" + + if operation == 'perimeter': + result = float(2 * pi * self.radius) + + elif operation == 'area': + result = float(pi * self.radius ** 2) + + else: + raise ValueError("Invalid operation. Please specify 'perimeter' or 'area'.") + + return result diff --git a/flask_app.py b/flask_app.py index 8897fa2..c2d2b63 100644 --- a/flask_app.py +++ b/flask_app.py @@ -1,6 +1,6 @@ from flask import Flask, render_template, request - from helper import perform_calculation, convert_to_float +from circle import Circle app = Flask(__name__) # create the instance of the flask class @@ -38,3 +38,26 @@ def calculate(): return render_template('calculator.html', printed_result="You cannot divide by zero") return render_template('calculator.html') + + +@app.route('/calculate_circle', methods=['GET', 'POST']) +def calculate_circle(): + if request.method == 'POST': + radius = request.form['radius'] + operation = str(request.form['operation']) + + try: + radius = convert_to_float(value=radius) + except ValueError: + return render_template('circle_calculator.html', printed_result="Cannot perform operation with this input") + + circle = Circle(radius) + result = circle.circle_calculation(operation=operation) + return render_template('circle_calculator.html', printed_result=str(result)) + + return render_template('circle_calculator.html') + + + +if __name__ == "__main__": + app.run(debug=True) \ No newline at end of file diff --git a/questions 2_3.docx b/questions 2_3.docx new file mode 100644 index 0000000..d4ec331 Binary files /dev/null and b/questions 2_3.docx differ diff --git a/static/.DS_Store b/static/.DS_Store new file mode 100644 index 0000000..846bf79 Binary files /dev/null and b/static/.DS_Store differ diff --git a/static/main.css b/static/main.css index dfe5192..3b241c9 100644 --- a/static/main.css +++ b/static/main.css @@ -1,10 +1,16 @@ +@import url('https://fonts.googleapis.com/css2?family=Comic+Neue&family=Papyrus&display=swap'); + + /* Global Styles */ body { - font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; - background-color: #f8f9fa; - color: #333; + font-family: 'Comic Neue', cursive, Tahoma, Geneva, Verdana, sans-serif; + font-size: 1em; + background-color: #2d7ccb; + color: #ffffff; margin: 0; padding: 0; + background-image: url('tie_dye.jpg'); + background-size: cover } .container { @@ -13,6 +19,14 @@ body { padding: 20px; } +h1 { + font-family: 'Comic Sans MS', 'Comic Sans', cursive; + font-size: 4em; + color: #FFFFFF; + font-weight: bold; + padding: 20px; +} + /* Header Styles */ header { background-color: #343a40; /* Dark neutral color for header */ @@ -56,8 +70,12 @@ h1 a { h1 a:hover { color: #ffafcc; + text-decoration: underline; /* re-adds underline on hover */ } + + + .menu li a:hover { color: #bde0fe; /* Light pastel color on hover */ } @@ -67,7 +85,7 @@ h1 { text-align: center; margin-top: 0; font-size: 36px; - color: #343a40; /* Dark neutral color for heading */ + color: #ffffff; /* Dark neutral color for heading */ } form { @@ -86,14 +104,19 @@ button { } button { - background-color: #343a40; /* Dark neutral color for button */ - color: #fff; + background-color: #FF69B4; + color: #FFFFFF; + font-family: 'Comic Neue', cursive; border: none; + padding: 10px 20px; + text-align: center; + display: inline-block; + margin: 4px 2px; cursor: pointer; - font-size: 16px; - transition: background-color 0.3s ease; /* Smooth transition for background color change */ + border-radius: 12px; + transition: background-color 0.3s ease; } button:hover { - background-color: #23272b; /* Slightly darker color on hover */ + background-color: #FFB6C1; } diff --git a/static/tie_dye.jpg b/static/tie_dye.jpg new file mode 100644 index 0000000..8fad555 Binary files /dev/null and b/static/tie_dye.jpg differ diff --git a/templates/calculator.html b/templates/calculator.html index 3dd1105..ed6df1c 100644 --- a/templates/calculator.html +++ b/templates/calculator.html @@ -1,6 +1,6 @@ {% extends 'layout.html' %} {% block content %} -