SEP-PYTHON

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART B

PROGRAM B1 PROGRAM B2 PROGRAM B3 PROGRAM B4 PROGRAM B5 PROGRAM B6 PROGRAM B7 . . .

 
  
 #7. Write a Program to create a calculator program.
------------------------------ 

print('Simple Calculator') 
while (True): 
    num1, num2 = map(float, input("Enter two numbers: ").split()) 
    print("Select operation:") 
    print("1. Add \n2. Subtract \n3. Multiply \n4. Divide \n5. Exit") 
    
    choice = input("Enter choice: ") 
    
    if choice == '1': 
        print(f"Result: {num1 + num2}") 
    elif choice == '2': 
        print(f"Result: {num1 - num2}") 
    elif choice == '3': 
        print(f"Result: {num1 * num2}") 
    elif choice == '4': 
        if num2 != 0: 
            print(f"Result: {num1 / num2}") 
        else: 
            print("Cannot divide by zero!") 
        elif choice == '5': break 
    else: 
        print("Invalid choice")