Python program to demonstrate simple calculator.
print("=== Python Simple Calculator ===")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
choice = input("\nEnter your choice: \n")
num1 = int(input("Enter number 1: "))
num2 = int(input("Enter number 2: "))
print("\nAnswer for Given Inputs:")
if choice == '1':
print(num1, "+", num2, "=", num1 + num2)
elif choice == '2':
print(num1, "-", num2, "=", num1 - num2)
elif choice == '3':
print(num1, "*", num2,"=", num1*num2)
elif choice == '4':
print(num1, "/", num2, "=", num1/num2)
else:
print("Invalid input.")
Output of program
1. Addition
2. Subtraction
3. Multiplication
4. Division
Enter your choice:
1
Enter number 1: 5
Enter number 2: 6
Answer for Given Inputs:
5 + 6 = 11
No comments:
Post a Comment