Calculator

    0

    9

    Mahendra Kumar

    mathsbeginner

    To make a simple calculator to perform addition, subtraction, multiplication and division.

    # take inputs
    num1 = float(input("Enter first number: "))
    num2 = float(input("Enter second number: "))
    # choise operation
    print("Operation: +, -, *, /")
    select = input("Select operations: ")
    # check operations and display result
    # add(+) two numbers
    if select == "+":
        print(num1, "+", num2, "=", num1+num2)
    # subtract(-) two numbers
    elif select == "-":
        print(num1, "-", num2, "=", num1-num2)
    # multiplies(*) two numbers
    elif select == "*":
        print(num1, "*", num2, "=", num1*num2)
    # divides(/) two numbers
    elif select == "/":
        print(num1, "/", num2, "=", num1/num2)
    else:
        print("Invalid input")
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.