diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6435913 --- /dev/null +++ b/.gitignore @@ -0,0 +1,68 @@ +# Python bytecode files +__pycache__/ +*.py[cod] +*$py.class + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Virtual environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# IDE files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db diff --git a/add_numbers.py b/add_numbers.py new file mode 100644 index 0000000..aaf71dc --- /dev/null +++ b/add_numbers.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +""" +Simple Python script to add two numbers together. +""" + +def add_numbers(num1, num2): + """ + Add two numbers together and return the result. + + Args: + num1 (float): First number + num2 (float): Second number + + Returns: + float: Sum of the two numbers + """ + return num1 + num2 + +def get_number_input(prompt): + """ + Get a number from user input with error handling. + + Args: + prompt (str): Prompt message to display to user + + Returns: + float: The number entered by the user + """ + while True: + try: + return float(input(prompt)) + except ValueError: + print("Please enter a valid number.") + +def main(): + """ + Main function that demonstrates the usage of add_numbers function. + Prompts user for two numbers, adds them, and displays the result. + """ + print("Welcome to the Number Addition Calculator!") + print("-" * 40) + + # Get input from user + first_number = get_number_input("Enter the first number: ") + second_number = get_number_input("Enter the second number: ") + + # Perform addition + result = add_numbers(first_number, second_number) + + # Display result + print(f"\nResult: {first_number} + {second_number} = {result}") + +if __name__ == "__main__": + main()