├── Task 2 .py ├── LICENSE └── README.md /Task 2 .py: -------------------------------------------------------------------------------- 1 | def calculator(): 2 | while True: 3 | num1 =float(input("Enter the first number: ")) 4 | num2 =float(input("Enter the second number: ")) 5 | operator =input("Enter operator (+, -, *, /): ") 6 | 7 | if operator == '+': 8 | result = num1 + num2 9 | elif operator == '-': 10 | result = num1 - num2 11 | elif operator == '*': 12 | result = num1 * num2 13 | elif operator == '/': 14 | if num2 == 0: 15 | print("Error: Division by zero") 16 | else: 17 | result = num1/num2 18 | else: 19 | print("Invalid operator") 20 | continue 21 | 22 | print("Result:", result) 23 | 24 | choice =input("Do you want to perform another calculation? (yes/no): ") 25 | if choice.lower() != "yes": 26 | break 27 | 28 | if __name__ == "__main__": 29 | calculator() 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Deepak L 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ViLearnx Task 2 - Simple Calculator 2 | 3 | ## Overview 4 | ViLearnx Task 2 is a simple calculator application developed in Python. It performs basic arithmetic operations including addition, subtraction, multiplication, and division, with error handling for division by zero. 5 | 6 | ## Features 7 | - **Addition**: Adds two numbers. 8 | - **Subtraction**: Subtracts one number from another. 9 | - **Multiplication**: Multiplies two numbers. 10 | - **Division**: Divides one number by another, with error handling for division by zero. 11 | 12 | ## Requirements 13 | - Python 3.x 14 | 15 | ## Installation 16 | 1. Clone the repository: 17 | ```bash 18 | git clone https://github.com/Deepak-L-coder/ViLearnx-Task-2.git 19 | ``` 20 | 2. Navigate to the project directory: 21 | ```bash 22 | cd ViLearnx-Task-2 23 | ``` 24 | 25 | ## Usage 26 | Run the calculator application: 27 | ```bash 28 | python calculator.py 29 | ``` 30 | Follow the prompts to perform calculations. 31 | 32 | ## Error Handling 33 | The application includes error handling for: 34 | - Division by zero 35 | - Invalid input 36 | 37 | ## Contributing 38 | Contributions are welcome! Please fork the repository and submit a pull request. 39 | 40 | ## License 41 | This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. 42 | 43 | ## Author 44 | Deepak L. Coder 45 | 46 | 47 | 48 | 49 | ## Screenshots 50 | 51 | 52 | ![Screenshot 2024-08-12 212337](https://github.com/user-attachments/assets/92ff48fe-0572-474a-939a-21a09d34bda4) 53 | 54 | 55 | ## Output 56 | 57 | ![Screenshot 2024-08-12 212455](https://github.com/user-attachments/assets/39080ad5-4cb1-4314-b6fe-efa748bdd7fa) 58 | --------------------------------------------------------------------------------