📌 Task 2 – Basic Calculator 🔢
📋 Project Title: Simple Arithmetic Calculator using Python
🧠 Description:
This project is a simple command-line calculator that allows users to perform basic arithmetic operations like:
➕ Addition
➖ Subtraction
✖️ Multiplication
➗ Division
The user is prompted to enter two numbers and choose the type of operation. The calculator then performs the selected operation and displays the result.
💡 Features:
✅ User-friendly input system
✅ Handles four basic operations
✅ Checks for division by zero
✅ Displays clear output messages
✅ Beginner-friendly Python code structure
🚀 How It Works:
The user enters the first number.
The user enters the second number.
The user selects an operation (1 to 4).
The calculator performs the operation and shows the result.
If the user divides by zero, it shows an error message.
🛠️ Tech Stack:
👨💻 Language: Python 3
🧮 Concepts Used: if-elif, user input, arithmetic operators, condition handling
🖥️ Sample Output:
C:\Users\Om\AppData\Local\Microsoft\WindowsApps\python3.11.exe C:\Users\Om\OneDrive\文档\GitHub\CODSOFT\CODSOFT_TASK2_CALCULATOR.py
Enter the first number: 90
Enter the second number: 38
Choose an operation:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/) Enter your choice: (1/2/3/4): 2) The Result is: 52.0
Process finished with exit code 0
C:\Users\Om\AppData\Local\Microsoft\WindowsApps\python3.11.exe C:\Users\Om\OneDrive\文档\GitHub\CODSOFT\CODSOFT_TASK2_CALCULATOR.py
Enter the first number: 220
Enter the second number: 92
Choose an operation:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
Enter your choice: (1/2/3/4): 3) The Result is: 20240.0
Process finished with exit code 0
C:\Users\Om\AppData\Local\Microsoft\WindowsApps\python3.11.exe C:\Users\Om\OneDrive\文档\GitHub\CODSOFT\CODSOFT_TASK2_CALCULATOR.py
Enter the first number: 184
Enter the second number: 23
Choose an operation:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
Enter your choice: (1/2/3/4): 4) The Result is: 8.0
Process finished with exit code 0
C:\Users\Om\AppData\Local\Microsoft\WindowsApps\python3.11.exe C:\Users\Om\OneDrive\文档\GitHub\CODSOFT\CODSOFT_TASK2_CALCULATOR.py
Enter the first number: 60
Enter the second number: 70
Choose an operation:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
Enter your choice: (1/2/3/4): 1) The Result is: 130.0
Process finished with exit code 0
C:\Users\Om\AppData\Local\Programs\Python\Python313\python.exe C:\Users\Om\OneDrive\文档\GitHub\CODSOFT\CODSOFT_TASK2_CALCULATOR.py
Enter the first number: 95
Enter the second number: 20
Choose an operation:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
Enter your choice: (1/2/3/4): 5)
Error: Invalid choice!!...Please select again!...1),2),3) or 4)
Process finished with exit code 0
📁 File: CODSOFT_TASK2_CALCULATOR.py — contains the complete code for the calculator.
🙌 Acknowledgement: This project is part of the Python Programming Internship offered by CodSoft.