diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d7de532 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Department of Climate, Meteorology & Atmospheric Sciences + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 9df9ede..05749f0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,48 @@ -# Create a README.md +# Rectangle Area Calculator 🟦 -If you need help with `Markdown`, check out [The Markdown Cheatsheet](https://www.markdownguide.org/cheat-sheet/)! +This repository contains a simple Python script that calculates the area of a rectangle based on user input. It was created in Visual Studio as part of ATMS 523 Assignment 1 to demonstrate basic Python functionality and GitHub workflows. -What should a good README.md look like? Check out these [guidelines](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-readmes). +## 🚀 How to Run -Did you add an open source software license? \ No newline at end of file +You do **not** need Visual Studio Code to run this script. Here's how to do it using just Python and a terminal: + +### 🧰 Step 1: Install Python +- Visit the [official Python website](https://www.python.org/downloads/) and download Python 3.x for your operating system. +- During installation, make sure to check the box that says **“Add Python to PATH”** (Windows only). + +### 📁 Step 2: Download the Script +- Go to this GitHub repository. +- Click the green **“Code”** button and select **“Download ZIP”**. +- Extract the ZIP file to a folder on your computer. + +### 📂 Step 3: Open a Terminal or Command Prompt +- **Windows**: Press `Win + R`, type `cmd`, and hit Enter. +- **macOS**: Open **Terminal** from Applications > Utilities. +- **Linux**: Use your system’s terminal. + +### 📍 Step 4: Navigate to the Folder +Use the `cd` command to move into the folder where the script is saved. For example: +``bash +cd Downloads/module-1-part-2-using-github-workflows-Key-Roberson-main + +### ▶️ Step 5: Run the Script +Type the following command: +python Simple_code.py + +### ✍️ Step 6: Follow the Prompts +Enter the length and width when asked. +The script will calculate and display the area of the rectangle. + +### 🧠 What It Does +- Prompts the user to enter the length and width of a rectangle. +- Calculates the area using a simple function. +- Displays the result with formatted output. +- Includes error handling for invalid input. + +### 🛠 Technologies Used +Python 3 +Visual Studio Code (JupyterHub environment) +Git & GitHub + +### 👩‍💻 Author +Created by Kiara Roberson for ATMS 523 Assignment 1. diff --git a/Simple_code.py b/Simple_code.py new file mode 100644 index 0000000..0b1e0e1 --- /dev/null +++ b/Simple_code.py @@ -0,0 +1,45 @@ +"""Rectangle Area Calculator. + +This script asks the user for the length and width of a rectangle, +calculates the area, and prints the result. +""" + +def calculate_area(length: float, width: float) -> float: + """Calculate the area of a rectangle. + + Args: + length (float): The length of the rectangle. + width (float): The width of the rectangle. + + Returns: + float: The calculated area. + """ + return length * width + + +def main(): + """Main function to run the area calculator.""" + print("Welcome to the Rectangle Area Calculator!") + + # Ask the user to enter the length and width + try: + length = float(input("Enter the length of the rectangle: ")) + width = float(input("Enter the width of the rectangle: ")) + except ValueError: + # Handle cases where the input is not a number + print("Oops! Please enter valid numbers for length and width.") + return + + # Call the function to calculate the area + area = calculate_area(length, width) + + # Display the results + print("\n--- Results ---") + print(f"Length: {length:.2f}") + print(f"Width: {width:.2f}") + print(f"Area of the rectangle: {area:.2f} square units") + + +# This ensures the main function runs only when the script is executed directly +if __name__ == "__main__": + main()