diff --git a/my-awesome-project/README.md b/my-awesome-project/README.md new file mode 100644 index 00000000..fd15211b --- /dev/null +++ b/my-awesome-project/README.md @@ -0,0 +1,32 @@ +\# Smart Calculator + + + +\## Description + +A command-line calculator that performs basic arithmetic operations. + + + +\## Features + +\- Add, Subtract, Multiply, Divide + +\- Input validation + +\- Prevents division by zero + + + +\## Usage + +Run: + +python app.py + + + +\## Technologies + +\- Python + diff --git a/my-awesome-project/app.py b/my-awesome-project/app.py new file mode 100644 index 00000000..7cc27725 --- /dev/null +++ b/my-awesome-project/app.py @@ -0,0 +1,41 @@ +def calculator(): + print("=== Smart Calculator ===") + + while True: + print("\nChoose operation:") + print("1. Add") + print("2. Subtract") + print("3. Multiply") + print("4. Divide") + print("5. Exit") + + choice = input("Enter choice (1-5): ") + + if choice == '5': + print("Exiting calculator...") + break + + if choice not in ['1','2','3','4']: + print("Invalid choice, try again!") + continue + + try: + a = float(input("Enter first number: ")) + b = float(input("Enter second number: ")) + except: + print("Invalid input! Enter numbers only.") + continue + + if choice == '1': + print("Result:", a + b) + elif choice == '2': + print("Result:", a - b) + elif choice == '3': + print("Result:", a * b) + elif choice == '4': + if b == 0: + print("Error: Division by zero!") + else: + print("Result:", a / b) + +calculator() \ No newline at end of file