Python Calculator with Basic Operations

🚀 Just built a simple Calculator using Python! Today I practiced basic programming concepts and created a calculator that can perform: ✅ Addition ✅ Subtraction ✅ Multiplication ✅ Division (with zero error handling) This project helped me understand: 🔹 if-elif-else conditions 🔹 User input handling 🔹 Basic error handling in Python Here’s a small snippet of my code 👇 num1 = float(input("Enter your first num: ")) num2 = float(input("Enter your second: ")) print("Select operation:") print("1 Add") print("2 Subtract") print("3 Multiply") print("4 Divide") choice = input("Enter choice (1/2/3/4): ") if choice == '1': print("Result:", num1 + num2) elif choice == '2': print("Result:", num1 - num2) elif choice == '3': print("Result:", num1 * num2) elif choice == '4': if num2 == 0: print("Error: Division by zero") else: print("Result:", num1 / num2) else: print("Invalid Input") Learning & Improving Every Day 🚀 💡 Today I practiced Python by building a simple calculator! Always exploring, always growing. #Python #Programming #Learning #Coding #Beginner #MdMoiz929

  • text

Thanks for pointing it out, Shivam! 👍 You're right, there was an indentation issue and I also missed the condition with "elif". I’ve corrected it now. Appreciate your feedback!

Like
Reply

Thanks! Yes, I’ve cleared some actuarial exams and working towards full qualification

Like
Reply

Thank you! I truly believe consistency and continuous learning are the keys to growth

Like
Reply

Line no. 18 after a condition use : IndentationError line no 20 And also 21 line no without condition because u r using elif than after using elif give the condition otherwise use else:

Keep the habit of practicing consistent. It really helps you in becoming the best version of yourself.

Like
Reply

The actual divide calculation is missing

Like
Reply

Line 2 should say input

Like
Reply
See more comments

To view or add a comment, sign in

Explore content categories