DEV Community

Mani Prabhu
Mani Prabhu

Posted on

First Python Program

while "True":

    print ("CALCULATOR")
    print ("Select Operation:")
    print ("1. Add")
    print ("2. Subtract")
    print ("3. Multiplication")
    print ("4. Division")
    print ("5. Modulus")
    print ("6. Exponentiate")

    choice = input("Enter Choice (1/2/3/4/5/6/7): ")

    if choice == "7":
       print ("Thank you for using calculator")

    elif choice < "7":

         num1 = float(input("Enter First Number:"))
         num2 = float(input("Enter Second Number:"))

    elif choice > "7":
         print ("Invalid Choice")

    # Addition

    if choice == "1":
       result = num1 + num2
       print ("result is: ", result)

    # Subtraction

    elif choice == "2":

       result = num1 - num2
       print ("result is: ", result)

    #Multiplication

    elif choice == "3":
       result = num1 * num2
       print ("result is: ", result)

    # Division


    elif choice == "4":
       result = num1 / num2
       print ("result is: ", result)
    # Remainder

    elif choice == "5":
       result = num1 % num2
       print ("result is: ", result)


    elif choice == "6":
       result = num1 ** num2
       print ("result is: ", result)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)