diff --git a/presentation/README.md b/presentation/README.md index d355456..8e6e08f 100644 --- a/presentation/README.md +++ b/presentation/README.md @@ -23,8 +23,15 @@ The `presentation` directory contains the following supporting files for the pre The `examples/` directory contains the following example code files: -- `example1.py`: Demonstrates a feature of GitHub Copilot Workspace. -- `example2.py`: Demonstrates another feature of GitHub Copilot Workspace. +- `math_operations/example1.py`: Demonstrates a feature of GitHub Copilot Workspace. +- `greetings/example2.py`: Demonstrates another feature of GitHub Copilot Workspace. + +## Subdirectories + +The `examples/` directory is organized into the following subdirectories: + +- `math_operations/`: Contains example code files related to mathematical operations. +- `greetings/`: Contains example code files related to greeting messages. Feel free to modify and experiment with the example code files to better understand how GitHub Copilot Workspace can assist you in your development workflow. diff --git a/presentation/examples/example2.py b/presentation/examples/greetings/example2.py similarity index 80% rename from presentation/examples/example2.py rename to presentation/examples/greetings/example2.py index 477521d..b579fe9 100644 --- a/presentation/examples/example2.py +++ b/presentation/examples/greetings/example2.py @@ -1,24 +1,23 @@ # Example 2: Demonstrating another feature of GitHub Copilot Workspace -def greet(name): +def greet(name: str) -> str: """ Function to greet a person by name. """ return f"Hello, {name}!" -def farewell(name): +def farewell(name: str) -> str: """ Function to bid farewell to a person by name. """ return f"Goodbye, {name}!" -def main(): +def main(name: str): """ Main function to demonstrate greeting and farewell. """ - name = "Alice" print(greet(name)) print(farewell(name)) if __name__ == "__main__": - main() + main("Alice") diff --git a/presentation/examples/example1.py b/presentation/examples/math_operations/example1.py similarity index 70% rename from presentation/examples/example1.py rename to presentation/examples/math_operations/example1.py index cea1ca6..669ed8c 100644 --- a/presentation/examples/example1.py +++ b/presentation/examples/math_operations/example1.py @@ -1,30 +1,31 @@ # Example 1: Demonstrating a feature of GitHub Copilot Workspace -def add(a, b): +def add(a: float, b: float) -> float: """ Function to add two numbers. """ return a + b -def subtract(a, b): +def subtract(a: float, b: float) -> float: """ Function to subtract two numbers. """ return a - b -def multiply(a, b): +def multiply(a: float, b: float) -> float: """ Function to multiply two numbers. """ return a * b -def divide(a, b): +def divide(a: float, b: float) -> float: """ Function to divide two numbers. """ - if b == 0: - raise ValueError("Cannot divide by zero") - return a / b + try: + return a / b + except ZeroDivisionError: + return float('inf') if __name__ == "__main__": x = 10