Monday, May 13, 2024

What is Business Intelligence?

What is Robotics?

What is Robotics?

 What is Robotics?


In simple terms, robotics combines science, engineering, and technology to design, construct, operate, and use machines programmed to replicate, substitute, or assist humans in completing tasks of varying complexity. These machines are known as robots.

Sunday, May 12, 2024

What is a Weight Training?

What is Information System?

Addition and Subtraction Using Polymorphism in Python

 class MathOperation:

    def perform_operation(self, a, b):

        return 0  # Base class default implementation


class Addition(MathOperation):

    def perform_operation(self, a, b):

        return a + b


class Subtraction(MathOperation):

    def perform_operation(self, a, b):

        return a - b


if __name__ == "__main__":

    operation = None

    num1, num2 = 0, 0


    print("\n\n\tAddition and Subtraction Using Polymorphism in Python\n")

    num1 = int(input("\tEnter the first number: "))

    num2 = int(input("\tEnter the second number: "))

    

    op = input("\tEnter the operation (+ for addition, - for subtraction): ")


    if op == '+':

        operation = Addition()

    elif op == '-':

        operation = Subtraction()

    else:

        print("\tInvalid operation.")

        exit()


    result = operation.perform_operation(num1, num2)

    print("\n\tThe Result:", result)


    print("\n\tEnd of Program. Thank you for using this program.")


Addition and Subtraction Using Polymorphism in Python