Join Community
Get in touch
Shushant
January 16, 2024
def add(x, y):
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
if y != 0:
return x / y
else:
return "Cannot divide by zero"
while True:
print("Select operation:")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
print("5. Exit")
choice = input("Enter choice (1/2/3/4/5): ")
if choice == '5':
print("Calculator exiting. Goodbye!")
break
if choice in ('1', '2', '3', '4'):
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
if choice == '1':
print("Add =" , num1 + num2)
elif choice == '2':
print("Subtract =" , num1 - num2)
elif choice == '3':
print("multiply =" , num1 * num2)
elif choice == '4':
print("divide =" , num1 / num2)
else:
print("Invalid input. Please enter a valid number (1/2/3/4/5).")
“Unlock Next-Level Web Development: Dive into Next.js 15’s Exciting Features!” +1
React Native Expo vs. React JS (Next.js): A Comprehensive Guide for Choosing the Right
Next.js: React's Next Evolution
Meet Devin , The World's First Software Engineer!
Python and Stock Market: A Simple and Brief Overview
Python Mastery Quest: 50 Engaging Challenges to Level Up Your Coding Skills
A Guide to ESLint: Enhancing JavaScript Code Quality
GitHub for Beginners: A Step-by-Step Guide to Pushing Your Code - Mastering the Basics and Essential Commands
Python Beginning: Simple Calculator
Snake Game Code: A Beginner's Guide
Easy Setup: Vite, React, TypeScript, and Tailwind Project Guide
Why you should prefer Zustand over Redux Toolkit?
Google launches Imagen 2, better than DALL.E 2?
Decoding the New AI Era: Is Gemini by Google the Ultimate ChatGPT Alternative?